ClickHouse Metrics via Telegraf
Ship your ClickHouse Metrics via Telegraf to your Logit.io Stack
Configure Telegraf to ship ClickHouse metrics to your Logit.io stacks via Logstash.
Follow this step by step guide to get 'logs' from your system to Logit.io:
Step 1 - Install Telegraf
This integration allows you to configure a Telegraf agent to send your metrics, in multiple formats, to Logit.io.
Telegraf is a flexible server agent equipped with plug-in support, useful for sending metrics and events from data sources like web servers, APIs, application logs, and cloud services.
To ship your metrics to Logit.io, we will integrate the relevant input and outputs.http plug-in into your Telegraf configuration file.
Choose the install for your operating system below to get started:
Windows
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.19.2_windows_amd64.zip
Download and extract to: C:\Program Files\Logitio\telegraf\
Configuration file: C:\Program Files\Logitio\telegraf\
MacOS
brew install telegraf
Configuration file x86_64 Intel: /usr/local/etc/telegraf.conf
Configuration file ARM (Apple Silicon): /opt/homebrew/etc/telegraf.conf
Ubuntu/Debian
wget -q https://repos.influxdata.com/influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update
sudo apt-get install telegraf
Configuration file: /etc/telegraf/telegraf.conf
RedHat and CentOS
cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo
[influxdata]
name = InfluxData Repository - Stable
baseurl = https://repos.influxdata.com/stable/\$basearch/main
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
EOF
sudo yum install telegraf
Configuration file: /etc/telegraf/telegraf.conf
SLES & openSUSE
zypper ar -f obs://devel:languages:go/ go
zypper in telegraf
Configuration file: /etc/telegraf/telegraf.conf
FreeBSD/PC-BSD
sudo pkg install telegraf
Configuration file: /etc/telegraf/telegraf.conf
Step 2 - Configure the Telegraf input plugin
The configuration file below is pre-configured to scrape the system metrics from your hosts, add the following code to the configuration file /etc/telegraf/telegraf.conf
from the previous step.
# Read metrics from one or many ClickHouse servers
[[inputs.clickhouse]]
## Username for authorization on ClickHouse server
username = "default"
## Password for authorization on ClickHouse server
# password = ""
## HTTP(s) timeout while getting metrics values
## The timeout includes connection time, any redirects, and reading the
## response body.
# timeout = 5s
## List of servers for metrics scraping
## metrics scrape via HTTP(s) clickhouse interface
## https://clickhouse.tech/docs/en/interfaces/http/
servers = ["http://127.0.0.1:8123"]
## If "auto_discovery"" is "true" plugin tries to connect to all servers
## available in the cluster with using same "user:password" described in
## "user" and "password" parameters and get this server hostname list from
## "system.clusters" table. See
## - https://clickhouse.tech/docs/en/operations/system_tables/#system-clusters
## - https://clickhouse.tech/docs/en/operations/server_settings/settings/#server_settings_remote_servers
## - https://clickhouse.tech/docs/en/operations/table_engines/distributed/
## - https://clickhouse.tech/docs/en/operations/table_engines/replication/#creating-replicated-tables
# auto_discovery = true
## Filter cluster names in "system.clusters" when "auto_discovery" is "true"
## when this filter present then "WHERE cluster IN (...)" filter will apply
## please use only full cluster names here, regexp and glob filters is not
## allowed for "/etc/clickhouse-server/config.d/remote.xml"
## <yandex>
## <remote_servers>
## <my-own-cluster>
## <shard>
## <replica><host>clickhouse-ru-1.local</host><port>9000</port></replica>
## <replica><host>clickhouse-ru-2.local</host><port>9000</port></replica>
## </shard>
## <shard>
## <replica><host>clickhouse-eu-1.local</host><port>9000</port></replica>
## <replica><host>clickhouse-eu-2.local</host><port>9000</port></replica>
## </shard>
## </my-onw-cluster>
## </remote_servers>
##
## </yandex>
##
## example: cluster_include = ["my-own-cluster"]
# cluster_include = []
## Filter cluster names in "system.clusters" when "auto_discovery" is
## "true" when this filter present then "WHERE cluster NOT IN (...)"
## filter will apply
## example: cluster_exclude = ["my-internal-not-discovered-cluster"]
# cluster_exclude = []
## Optional TLS Config
# tls_ca = "/etc/telegraf/ca.pem"
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Use TLS but skip chain & host verification
# insecure_skip_verify = false
Step 3 - Configure the output plugin
Once you have generated the configuration file, you need to set up the output plug-in to allow Telegraf to transmit your data to Logit.io in Prometheus format. This can be accomplished by incorporating the following code into your configuration file:
[[outputs.http]]
url = "https://<your-metrics-username>:<your-metrics-password>@<your-metrics-stack-id>-vm.logit.io:0/api/v1/write"
data_format = "prometheusremotewrite"
[outputs.http.headers]
Content-Type = "application/x-protobuf"
Content-Encoding = "snappy"
Step 4 - Start Telegraf
Windows
telegraf.exe --service start
MacOS
telegraf --config telegraf.conf
Linux
sudo service telegraf start
for systemd installations
systemctl start telegraf
Step 5 - View your metrics
Data should now have been sent to your Stack.
If you don't see metrics take a look at How to diagnose no data in Stack below for how to diagnose common issues.
Step 6 - How to diagnose no data in Stack
If you don't see data appearing in your Stack after following the steps, visit the Help Centre guide for steps to diagnose no data appearing in your Stack or Chat to support now.
Step 7 - Telegraf ClickHouse metrics Overview
In order to effectively monitor and analyze ClickHouse metrics in a distributed environment, having a reliable and efficient metrics management solution is key. Telegraf, an open-source agent known for collecting and sending metrics, is a perfect tool for gathering ClickHouse metrics from numerous sources, such as operational ClickHouse databases, other related applications, and the underlying infrastructure.
Telegraf boasts an array of input plugins, enabling users to collect metrics from diverse sources like CPU usage, memory consumption, network activity, and many more. For storing and querying these amassed metrics, organizations can employ Prometheus, an open-source system that offers both monitoring and alerting capabilities. This tool supports a flexible querying language and has strong graphical data visualization features.
To ship ClickHouse metrics from Telegraf to Prometheus, organizations need to configure Telegraf to output metrics in the Prometheus format. Then, they can use Prometheus to scrape these metrics from the Telegraf server. This process involves setting up Telegraf to collect ClickHouse metrics and output them in the Prometheus format, configuring Prometheus to retrieve these metrics from the Telegraf server, and then visualizing and analyzing the data using Prometheus's versatile querying and visualization capabilities.
Once the metrics are in Prometheus, further analysis and visualization can be performed using Grafana. Grafana is an open-source platform that's perfect for monitoring and observability and is entirely compatible with Prometheus. It provides users with the tools to create dynamic and interactive dashboards, enabling them to dig deeper into the metrics data.
If you need any further assistance with shipping your log data to Logit.io we're here to help you get started. Feel free to get in contact with our support team by sending us a message via live chat & we'll be happy to assist.