cyrus

cyrus

梦想是做一名可以“养活”自己的自由职业者 --自由不是你想做什么就做什么 而是不想做什么就不做什么.
github
twitter
bilibili

Prometheus+Grafana I heard that the big shots are using this to monitor flink metrics.

Architecture#

Simple drawing and shallow understanding

  • Flink has a built-in plugin for interacting with Prometheus in the native environment.
  • Prometheus is used for metric collection.
    • Node-exporter is used.
    • Pushgateway is used.
  • Grafana is mainly for personalized dashboards. Although Prometheus pages can be viewed, they are not aesthetically pleasing.

image

Environment#

Environment/ComponentVersion
Operating SystemCentOS Linux release 7.9.2009 (Core)
DockerDocker version 1.13.1
Flink1.13.6 on docker

Deployment#

Prometheus+Grafana are all deployed on Docker.

  1. Preparation

In Linux:

mkdir /opt/grafana-storage  # Grafana data storage directory
chmod -R 777 /opt/grafana-storage
vim /opt/prometheus/prometheus.yml   # Create and edit

prometheus.yml (Don't forget to modify the IP)

global:
  scrape_interval:     60s
  evaluation_interval: 60s
 
scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']
        labels:
          instance: prometheus
 
  - job_name: linux
    static_configs:
      - targets: ['ip:9100']
        labels:
          instance: localhost
  - job_name: 'pushgateway'
    static_configs:
      - targets: ['ip:9091']
        labels:
          instance: 'pushgateway'

Add to the Flink configuration file:

metrics.reporter.promgateway.class: org.apache.flink.metrics.prometheus.PrometheusPushGatewayReporter
metrics.reporter.promgateway.host: ip
metrics.reporter.promgateway.port: 9091
metrics.reporter.promgateway.jobName: flink
metrics.reporter.promgateway.randomJobNameSuffix: true
metrics.reporter.promgateway.deleteOnShutdown: true

  1. Deployment
mkdir /opt/grafana-storage
chmod -R 777 /opt/grafana-storage

docker run -d -p 3000:3000  --name=grafana   -v /opt/grafana-storage:/var/lib/grafana   grafana/grafana


docker run -d -p 9100:9100  -v "/proc:/host/proc:ro"  -v "/sys:/host/sys:ro"  -v "/:/rootfs:ro"  --net="host"  prom/node-exporter


docker run -d -p 9090:9090  -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  prom/prometheus

docker run -d -p 9091:9091 prom/pushgateway

Start a Flink job for testing.

  1. Observation

Check the startup status of the Prometheus suite through the gateway (up means started)
http://ip:9090/targets#pool-pushgateway

Check the monitored Flink jobs through the gateway
http://ip:9091

Practice#

  • Add Prometheus source to Grafana

Settings -> Add Prometheus
image
Add URL and click save.

  • Add Grafana dashboard templates

Search for templates in the Grafana dashboard library and copy the ID.
https://grafana.com/grafana/dashboards/

Import the Grafana dashboard by adding the ID, which will be downloaded automatically.
image

Then adjust as needed.

image

image

Some templates may not have data, not sure why.

image

Next Steps#

  • Configure monitoring indicators in the Flink process, such as benchmark QPS, data volume, and latency.
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.