Exporting metrics with an existing Prometheus server
After configuring DSE Metrics Collector, you can export metrics to an existing Prometheus server. These steps use Prometheus as the monitoring solution and Grafana as the dashboard. However, other monitoring and visualization tools can be used with DSE Metrics Collector.
If you already have a Prometheus server running, this method of exporting and visualizing metrics enables use of the existing server.
For clusters managed by Lifecycle Manager (LCM) 6.7 and later, you can use LCM to export metrics collection to Prometheus, which replaces steps 2-4 in this procedure. |
Prerequisites
-
If necessary, download and install DataStax Enterprise (DSE 6.7.0 or later | 6.0.5 or later | 5.1.14 or later).
-
Download and install Prometheus, which is used as the monitoring solution, or use an existing Prometheus server.
-
Download and install Grafana, which is used as the visualization dashboard.
-
Download the prometheus.yml file from GitHub and save it in a directory on the server where Prometheus is running.
The
prometheus.yml
file is preconfigured to scrape metrics reported by DSE Metrics Collector. Each metric uses a specific regex for the metric type.If you are already using a
prometheus.yml
, integrate themetric_relabel_configs:
block, which is where DSE metrics are relabelled using regular expressions in your existingprometheus.yml
file. -
Download the tg_dse.json file and save it in the same directory as the
prometheus.yml
file.The
prometheus.yml
file references this file to obtain the IP addresses for each cluster node. -
To use preconfigured Grafana dashboards from DataStax, download the JSON files from GitHub to your local machine. Place these files in a local directory that is accessible.
Procedure
-
On the server where Prometheus is running, ensure the
prometheus.yml
andtg_dse.json
files are collocated in the same directory. -
On the DSE cluster that DSE Metrics Collector reads from, create a
/collectd
directory:-
Package installations: Create the
/etc/dse/collectd
directory on all nodes in the cluster and set the required user permissions. -
Tarball installations: The
installation_location/resources/dse/collectd/etc/collectd
exists by default.
-
-
Configure the Prometheus server from which the DSE Metrics Collector reads.
-
Create a
prometheus.conf
file in thecollectd
directories:sudo touch prometheus.conf
-
Define the Prometheus plugin:
LoadPlugin write_prometheus <Plugin write_prometheus> Port "9103" </Plugin>
-
To propagate the changes, disable and then re-enable DSE Metrics Collector on any node in the cluster:
dsetool insights_config --mode DISABLED
Disabling DSE Metrics Collector can take up to 30 seconds to propagate across the cluster. Wait at least 30 seconds before re-enabling DSE Metrics Collector.
dsetool insights_config --mode ENABLED_WITH_LOCAL_STORAGE
-
-
Ensure collectd is listening on port 9103, in addition to the typical DSE ports:
netstat -lnt
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 10.100.176.166:9042 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 10.100.176.166:7000 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN tcp 0 0 10.100.176.166:8609 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:39940 0.0.0.0:* LISTEN tcp6 0 0 :::9103 :::* LISTEN tcp6 0 0 10.100.176.166:61621 :::* LISTEN tcp6 0 0 :::22 :::* LISTEN
If collectd is not listening on port 9103, ensure libaio is installed and Epoll is working. The collectd daemon will not start if Epoll is not working.
-
Modify the downloaded
tg_dse.json
file to include the IP address of each node in the cluster under"targets"
.The list of IP addresses is comma-delimited. Enclose each IP address in double quotation marks.
-
Start Prometheus with the
--config
option to specify theprometheus.yml
file you downloaded from the DSE Metrics Collector Dashboards repository.For example, if you saved the
prometheus.yml
file in the/etc/dse/tmp directory
, the command would look like this:./prometheus --config.file=/etc/dse/tmp/prometheus.yml
-
Verify the Prometheus and Grafana targets:
-
To view the Prometheus dashboard, which displays each DSE node as a target, open a browser and navigate to
http://prometheus_server_IP_address:9090
, where prometheus_server_IP_address is the IP address where the Prometheus server is running, and 9090 is the default port where Prometheus runs. -
To view the targets that Prometheus is monitoring, open a browser and navigate to
http://prometheus_server_IP_address:9090/targets
. Each of the nodes specified in thetg_dse.json
file displays as an endpoint, with the current status and last scrape time.
-
Creating a Grafana dashboard using the Prometheus data source
You can create a Grafana dashboard to visualize metrics. The Prometheus plugin is included with Grafana. These steps apply when an existing Prometheus server exports DSE metrics.
Prerequisites
Complete the required configuration in Exporting metrics with an existing Prometheus server.
Procedure
-
Start Grafana and enable the Prometheus plugin, which is included with Grafana by default.
You must have admin privileges for your organization to add data sources in Grafana.
-
Log in to your Grafana instance at
http://grafana_server_IP_address:3000
, where grafana_server_IP_address is the IP address where your Grafana server is running. -
Open the side menu by selecting the Grafana icon in the upper left.
-
In the side menu, select Configuration > Data Sources.
-
On the Configuration page, select Add data source.
-
Enter a name for your data source.
-
Select Prometheus as the data source Type.
-
Enter the URL where your Prometheus server is running.
-
Select Server or Browser, depending on where your Prometheus instance is running.
-
Select Save & Test.
-
-
Create a Grafana dashboard using the Prometheus data source.
-
Log in to your Grafana instance.
-
In the side menu, select Create > Import.
-
Select Upload .json file and select one of the preconfigured Grafana dashboard JSON files you downloaded earlier.
For example,
dse-cluster-condensed.json
. -
Enter a name for the dashboard and select Import.
-