Monitor kafka with Prometheus and Grafana - apache-kafka

I have followed the below steps to monitor kafka with Prometheus and Grafana.
jmx port not get opened
wget http://ftp.heanet.ie/mirrors/www.apache.org/dist/kafka/0.10.1.0/kafka_2.11-0.10.1.0.tgz
tar -xzf kafka_*.tgz
cd kafka_*
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.6/jmx_prometheus_javaagent-0.6.jar
wget https://raw.githubusercontent.com/prometheus/jmx_exporter/master/example_configs/kafka-0-8-2.yml
./bin/zookeeper-server-start.sh config/zookeeper.properties &
KAFKA_OPTS="$KAFKA_OPTS -javaagent:$PWD/jmx_prometheus_javaagent-0.6.jar=7071:$PWD/kafka-0-8-2.yml"
./bin/kafka-server-start.sh config/server.properties &
Then i have the checked with curl http://localhost:7071/metrics in the terminal
it reports curl: (7) Failed connect to localhost:7071; Connection refused
Currently i have opened all my ports to my network in the server.
while i m checking with netstat -tupln | grep LISTEN
port number 7071 was not listed in the output
The below is the kafka directory's contents:
drwxr-xr-x. 3 root root 4096 Aug 23 12:22 bin
drwxr-xr-x. 2 root root 4096 Oct 15 2016 config
-rw-r--r--. 1 root root 20356 Aug 21 10:50 hs_err_pid1496.log
-rw-r--r--. 1 root root 19432 Aug 21 10:55 hs_err_pid2447.log
-rw-r--r--. 1 root root 1225418 Feb 5 2016 jmx_prometheus_javaagent-0.6.jar
-rw-r--r--. 1 root root 2824 Aug 21 10:48 kafka-0-8-2.yml
drwxr-xr-x. 2 root root 4096 Aug 21 10:48 libs
-rw-r--r--. 1 root root 28824 Oct 5 2016 LICENSE
drwxr-xr-x. 2 root root 4096 Oct 11 15:05 logs
-rw-------. 1 root root 8453 Aug 23 12:08 nohup.out
-rw-r--r--. 1 root root 336 Oct 5 2016 NOTICE
drwxr-xr-x. 2 root root 46 Oct 15 2016 site-docs
kafka is running in 2181 port and zookeeper is also running

If you do not mind opening up the jmx port, you can also do it like this:
export JMX_PORT=9999
export KAFKA_JMX_OPTS=-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=9999'
./bin/kafka-server-start.sh config/server.properties &
java -jar jmx_prometheus_httpserver-0.10-jar-with-dependencies.jar 9300 kafka-0-8-2.yaml &
The jar-with-dependencies you build from the source with mvn package.

I had the same problem when setting KAFKA_OPTS environment variable in the bash. The worse situation is when you add the environment variable to ~/.profile file. The problem with this approach is that the KAFKA_OPTS is used for both kafka-server-start.sh and zookeeper-server-start.sh so when you start Zookeeper, port 7071 will be used by Zookeeper for exporting metrics. Then, when you run Kafka you will receive the "7071 port is in use error".
I solved the problem by setting the environment at systemd service file. I described it at my article last week:
[Unit]
...
[Service]
...
Restart=no
Environment=KAFKA_OPTS=-javaagent:/home/morteza/myworks/jmx_prometheus_javaagent-0.9.jar=7071:/home/morteza/myworks/kafka-2_0_0.yml
[Install]
...

Related

pod logs not stored in EKS nodes

I am trying to configure a fluend to send logs to an elasticsearch. After configuring it, I could not see any pod logs in the elasticsearch.
While debuging what is happening, I have seen that there are no logs in the node in path var/log/pods:
cd var/logs/pods
ls -la
drwxr-xr-x. 34 root root 8192 Dec 9 12:26 .
drwxr-xr-x. 14 root root 4096 Dec 9 02:21 ..
drwxr-xr-x. 3 root root 21 Dec 7 03:14 pod1
drwxr-xr-x. 6 root root 119 Dec 7 11:17 pod2
cd pod1/containerName
ls -la
total 0
drwxr-xr-x. 2 root root 6 Dec 7 03:14 .
drwxr-xr-x. 3 root root 21 Dec 7 03:14 ..
But I can see the logs when executing kubectl logs pod1
As I have seen in the documentation logs should be in this path. Do you have any idea why there are no logs stored in the node?
I have found what was happening. The problem was related with the log driver. It was configured to send the logs to journald:
docker inspect -f '{{.HostConfig.LogConfig.Type}}' ID
journald
I have changed it to json-file. Now it is writing logs var/log/pods
Here there are the different logging configuration options

VS code setup for Java remote development

few weeks back vscode made JDK-11 mandatory for java development in VS-code
The Eclipse Platform has decided to require Java 11 as the minimum requirement for its September 2020 release. See https://www.eclipse.org/lists/eclipse-pmc/msg03821.html.
Because vscode-java depends on the Eclipse JDT.LS, the same requirement applies to vscode-java but on a more agressive timeline: vscode-java usually consumes JDT.LS builds that depend on bleeding edge JDT features, effectively shipping pre-release versions of Eclipse Platform/JDT. As of July 22nd, 2020, Java 11 is now required for running vscode-java.
source: vscode
i am using remote ssh extension to connect to my remote VM (ubuntu on vagrant).
when i open Java file in remote-ssh ,i am getting error saying install Java 11.
i have the java 11 already in my vagrant.
i can see the following in my VM
$ update-java-alternatives -l
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
vagrant#vagrant:/usr/lib/jvm
$ ls
total 24K
drwxr-xr-x 4 root root 4.0K Feb 21 2020 .
drwxr-xr-x 138 root root 4.0K Aug 13 17:57 ..
lrwxrwxrwx 1 root root 25 Feb 20 2019 default-java -> java-1.11.0-openjdk-amd64
lrwxrwxrwx 1 root root 21 Jan 15 2020 java-1.11.0-openjdk-amd64 -> java-11-openjdk-amd64
-rw-r--r-- 1 root root 2.0K Jan 15 2020 .java-1.11.0-openjdk-amd64.jinfo
drwxr-xr-x 7 root root 4.0K Feb 21 2020 java-11-openjdk-amd64
lrwxrwxrwx 1 root root 20 Jan 17 2020 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64
-rw-r--r-- 1 root root 2.7K Jan 17 2020 .java-1.8.0-openjdk-amd64.jinfo
drwxr-xr-x 7 root root 4.0K Feb 21 2020 java-8-openjdk-amd64
all my java projects depends on java-8 so just to work with in vscode , i need Java-11.
please help me to setup this Env.
The easiest is to change your java config with the following command:
sudo alternatives --config java
and choose the Java version you want active.

install Ansible on Centos 6.9

i have a machine with CentOS 6.9 as OS and it is minimal. i was trying to install Ansible on my machine. i can't connect my machine to internet to set repository and install Ansible so i downloaded ansible.tar.gz. what shoud i do to install it?
the content of tar file:
drwxr-xr-x. 2 root root 4096 Mar 14 22:33 bin
drwxr-xr-x. 2 root root 4096 Mar 14 22:33 changelogs
drwxr-xr-x. 3 root root 4096 Mar 14 22:33 contrib
-rw-r--r--. 1 root root 35148 Mar 14 22:33 COPYING
drwxr-xr-x. 6 root root 4096 Mar 14 22:33 docs
drwxr-xr-x. 3 root root 4096 Mar 14 22:33 examples
drwxr-xr-x. 3 root root 4096 Mar 14 22:33 lib
drwxr-xr-x. 2 root root 4096 Mar 14 22:33 licenses
-rw-r--r--. 1 root root 13416 Mar 14 22:33 Makefile
-rw-r--r--. 1 root root 759 Mar 14 22:33 MANIFEST.in
drwxr-xr-x. 10 root root 4096 Mar 14 22:33 packaging
-rw-r--r--. 1 root root 7298 Mar 14 22:33 PKG-INFO
-rw-r--r--. 1 root root 4752 Mar 14 22:33 README.rst
-rw-r--r--. 1 root root 371 Mar 14 22:33 requirements.txt
-rw-r--r--. 1 root root 10714 Mar 14 22:33 setup.py
-rw-r--r--. 1 root root 3624 Mar 14 22:33 shippable.yml
-rw-r--r--. 1 root root 5565 Mar 14 22:33 SYMLINK_CACHE.json
drwxr-xr-x. 11 root root 4096 Mar 14 22:33 test
-rw-r--r--. 1 root root 1129 Mar 14 22:33 tox.ini
i tried to install epel then install ansible but i had no success:
rpm -ivh epel-release-6-8.noarch.rpm
Refer to ansible docs. It explained how to install by building it yourself at the end of this part.
You can also build an RPM yourself. From the root of a checkout or
tarball, use the make rpm command to build an RPM you can distribute
and install.
git clone https://github.com/ansible/ansible.git
cd ./ansible
make rpm
sudo rpm -Uvh ./rpm-build/ansible-*.noarch.rpm

How to upgrade zookeeper from from 3.4.8 to 3.4.13?

I am trying to upgrade zookeeper from 3.4.8 to 3.4.13.
Before upgrade the content of /usr/lib/zookeeper
drwxr-xr-x 5 root root 4.0K Aug 23 08:39 .
drwxr-xr-x 77 root root 12K Aug 23 08:50 ..
drwxr-xr-x 2 root root 4.0K Aug 23 08:39 bin
lrwxrwxrwx 1 root root 19 May 24 11:25 conf -> /etc/zookeeper/conf
drwxr-xr-x 2 root root 4.0K Aug 23 08:39 lib
-rw-r--r-- 1 root root 12K May 24 11:25 LICENSE.txt
-rw-r--r-- 1 root root 170 May 24 11:25 NOTICE.txt
-rw-r--r-- 1 root root 1.3M Aug 23 08:39 zookeeper-3.4.8.jar
lrwxrwxrwx 1 root root 38 Aug 23 08:39 zookeeper.jar -> /usr/lib/zookeeper/zookeeper-3.4.8.jar
As mentioned in answer I have downloaded the zookeeper from this link and placed the zookeeper-3.4.13.jar in /usr/lib/zookeeper and pointed the symbolic link like below
lrwxrwxrwx 1 root root 39 Aug 30 03:19 zookeeper.jar -> /usr/lib/zookeeper/zookeeper-3.4.13.jar
But on checking the status after resarting zookeeper it is still pointing to 3.4.8
ubuntu#vrni-platform:/etc/zookeeper/conf$ telnet localhost 2181
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
status
Zookeeper version: 3.4.8--1, built on 02/06/2016 03:18 GMT
It appears this is because of the way the jars are loaded from /usr/lib/zookeeper/bin/zkEnv.sh
#release tarball format
for i in "$ZOOBINDIR"/../zookeeper-*.jar
do
CLASSPATH="$i:$CLASSPATH"
done
Can someone let me know is this some known issue is zkEnv.sh? Is this expected?
This has been answered in zookeeper mailing list. We should not have multiple zookeeper-<version>.jar in the CLASSPATH.

How to start 'mongos' route server (MongoDB 2.1.1) on Raspbian?

So i used THIS Tutorial from Eugene Ch'ng for setting up a MongoDB Shard-Cluster. Following all his steps works perfect.
My cluster contains 4 raspberry-pi (b+) and my MacBook.
After setting up my Config-Server (only one for now, due to hardware shortage), i came to the point where i should start the "mongos" instance. But there is none.
/opt/mongo/bin contains:
pi#pi01 /opt/mongo/bin $ ls -l
total 48536
-rwxr-xr-x 1 root root 4986476 May 28 20:16 bsondump
drwxr-xr-x 2 root root 4096 Jun 1 08:24 cfg0
-rw-r--r-- 1 root root 2376 May 29 10:34 log.cfg0
-rwxr-xr-x 1 root root 2734964 May 28 20:28 mongo
-rwxr-xr-x 1 root root 6942152 May 28 20:28 mongod
-rwxr-xr-x 1 root root 5006660 May 28 20:32 mongodump
-rwxr-xr-x 1 root root 4990416 May 28 20:36 mongoexport
-rwxr-xr-x 1 root root 5018040 May 28 20:39 mongofiles
-rwxr-xr-x 1 root root 5007712 May 28 20:43 mongoimport
-rwxr-xr-x 1 root root 4977940 May 28 20:47 mongooplog
-rwxr-xr-x 1 root root 4990044 May 28 20:50 mongoperf
-rwxr-xr-x 1 root root 5013980 May 28 20:54 mongorestore
Even this wasn't helping me:
sudo find / -name 'mongos'
Where can i find the 'mongos' process to start the mongodb route-server?
Thank you for your help in advance.