参考网址
JMX agent:https://github.com/prometheus/jmx_exporter
JMX agent: https://github.com/nabto/cassandra-prometheus
Prometheus+Grafana = https://prometheus.io/docs/visualization/grafana/
Grafana模板: https://grafana.com/dashboards/371
Cassandra集成prometheus的一个说明: https://www.robustperception.io/monitoring-cassandra-with-prometheus/
安装JMX exporter java agent
进到Cassandra Home目录
wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.9/jmx_prometheus_javaagent-0.9.jar
wget https://raw.githubusercontent.com/prometheus/jmx_exporter/master/example_configs/cassandra.yml
echo 'JVM_OPTS="$JVM_OPTS -javaagent:'$PWD/jmx_prometheus_javaagent-0.9.jar=7070:$PWD/cassandra.yml'"' >> conf/cassandra-env.sh
重启Cassandra,就会通过这个agent响应外部的抓取监控数据请求。
安装Prometheus
docker run -itd -p 9090:9090 -v /etc/localtime:/etc/localtime:ro -v /prometheus-data:/prometheus-data -v /prometheus-data/prometheus.yml:/etc/prometheus/prometheus.yml --privileged prom/prometheus
修改prometheus.yml,修改后重启docker
cat <<'EOF' > prometheus.yml
global:
scrape_interval: 10s
evaluation_interval: 10s
scrape_configs:
- job_name: 'cassandra'
static_configs:
- targets:
- localhost:7070
EOF
点击http://prometheus_host:9090/如果看到界面,说明安装成功。
安装grafana
docker run \
-d \
-p 3000:3000 \
--name=grafana \
-v /etc/localtime:/etc/localtime:ro \
-v /var/lib/grafana:/var/lib/grafana \
-v /etc/grafana/:/etc/grafana \
grafana/grafana
点击http://grafana_host:3000/登录进系统,默认密码是admin/admin。添加数据源,就是Prometheus的URL,比如http://prometheus_host:9090/
界面上操作,导入Cassandra的dashboard模板,https://grafana.com/dashboards/371
注意
grafana添加prometheus数据源应该是首字母大写Prometheus,不然模板会找不到数据源