You can use Telegraf to collect metric data from Kafka servers, and then use Logtail to send the metric data to a Metricstore in Log Service. This way, you can monitor metric data of Kafka servers in a visualized manner. This topic describes how to use Log Service to collect metric data from Kafka servers and visualize the data.
Prerequisites
- Logtail V0.16.48 or later is installed on a Linux server. For more information, see Install Logtail on a Linux server.
- Java 1.6 or later is installed on the server.
Step 1: Create a Logtail configuration
Step 2: Configure JavaAgent
After the Logtail configuration is created, you must enable access to JMX data over
HTTP. Log Service allows you to use Jolokia to access JMX data over HTTP. You can download and load Jolokia based on the official
documentation of Jolokia. You can also use Jolokia JavaAgent that is provided together
with Logtail in Log Service. Jolokia JavaAgent is stored in /etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar
.
KAFKA_JVM_PERFORMANCE_OPTS
environment variable on your Kafka server. For example, specify export KAFKA_JVM_PERFORMANCE_OPTS=-javaagent:/etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar=port=7777
. In this example, 7777 indicates the port number of your Kafka server, and the port number is the same as
the port number that you specify in Step 1: Create a Logtail configuration.
-javaagent:/tmp/jolokia-jvm.jar=port=7777,host=0.0.0.0
java -jar /etc/ilogtail/telegraf/javaagent/jolokia-jvm.jar --port 7777 start PID
Jolokia is already attached to PID 752
http://127.0.0.1:7777/jolokia/
curl http://127.0.0.1:7777/jolokia/
# Sample response
{"request":{"type":"version"},"value":{"agent":"1.6.2","protocol":"7.2","config":{"listenForHttpService":"true","maxCollectionSize":"0","authIgnoreCerts":"false","agentId":"30.43.124.186-752-5b091b5d-jvm","debug":"false","agentType":"jvm","policyLocation":"classpath:\/jolokia-access.xml","agentContext":"\/jolokia","serializeException":"false","mimeType":"text\/plain","maxDepth":"15","authMode":"basic","authMatch":"any","discoveryEnabled":"true","streaming":"true","canonicalNaming":"true","historyMaxEntries":"10","allowErrorDetails":"true","allowDnsReverseLookup":"true","realm":"jolokia","includeStackTrace":"true","maxObjects":"0","useRestrictorService":"false","debugMaxEntries":"100"},"info":{"product":"tomcat","vendor":"Apache","version":"8.5.57"}},"timestamp":1602663330,"status":200}⏎
FAQ
How can I check whether Telegraf collects data as expected?
You can check the logs of the /etc/ilogtail/telegraf/telegraf.log file on your server. You can also collect this log file to Log Service and search for the required information.
What to do next
- Search and analyze
After you complete the settings, Telegraf uses the Logtail to upload collected metrics to the Metricstore of Log Service. You can query the data on the Search & Analysis page of the Metricstore. For more information, see Query and analyze time series data.
- Visualization
After the configuration for your Kafka server is complete, Log Service automatically creates a dashboard named Kafka Monitoring Data_<Cluster name> in the project that is used. In the dashboard, you can perform various operations. For example, you can view query results and configure alerts.