1.prometheus
nohup ./prometheus --config.file=prometheus.yml &
prometheus.yml
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
external_labels:
component_typeName: Prometheus
component_name: prometheus_remote_write_Prometheus Remote Write数据源
component_builtin: 0
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# scheme: 'https'
# tls_config:
# insecure_skip_verify: true
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
- job_name: node
static_configs:
- targets: ['localhost:9100', 'localhost:9101']
- job_name: mysql
static_configs:
- targets: ['localhost:9103']
- job_name: docker-cadvisor
static_configs:
- targets: ['localhost:8082']
- job_name: statsd
static_configs:
- targets: ['localhost:9102']
# remote write config
remote_write:
- url: http://ip:port/APM/prom/push?pv=590848&pfg=AAD&pft=2&acid=86030311-df2a-11ed-8eb2-5a18c2525e2c&msgtype=0&mid=AF10BB3A-F9EE-5831-E666-000000000000
#- url: http://ip:port/APM/prom/push?pv=590848&pfg=AAD&pft=2&acid=b3396acc-ea18-4c46-bb1a-8fcf5baf6e9f&msgtype=0&mid=4588A369-3BD2-0E48-B56A-86B87C9EB906
#write_relabel_configs:
# url: http://localhost:8080/api/v1/write
# basic_auth:
# username: access-key-id
# password: access-key-secret
#queue_config:
# batch_send_deadline: 20s
# capacity: 20480
#max_backoff: 5s
#max_samples_per_send: 2048
#min_backoff: 100ms
#min_shards: 100
2.node_exporter
node_exporter:
[Unit]
Description=node_exporter
After=network.target
[Service]
ExecStart=/usr/local/bin/node_exporter\
--web.listen-address=:9101\
--collector.systemd\
--collector.systemd.unit-whitelist=(sshd|nginx).service\
--collector.processes\
--collector.tcpstat
[Install]
WantedBy=multi-user.target
3.mysql_exporter
mysql_exporter:
vim /etc/systemd/system/mysqld_exporter.service
systemctl daemon-reload
systemctl enable --now mysqld_exporter
systemctl status mysqld_exporter
[Unit]
Description=mysqld monitor
After=network.target
[Service]
Environment=DATA_SOURCE_NAME=username:password@(ip:3306)/
ExecStart=/usr/local/bin/mysqld_exporter --web.listen-address=:9103
ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5
TimeoutStopSec=5
KillMode=mixed
[Install]
WantedBy=multi-user.target
4.kafka_exporter
[Unit]
Description=kafka_exporter
After=local-fs.target network-online.target network.target
Wants=local-fs.target network-online.target network.target
[Service]
ExecStart=/usr/local/bin/kafka_exporter --kafka.server=ip:9092 --web.listen-address=:9038
Restart=on-failure
[Install]
WantedBy=multi-user.target
5.查询的时候
{job="mysql"}
6.OpenMetrics规范
指标名称(Metric name):指标的唯一标识符,通常采用键值对的方式组织。
指标样本(Samples):一个时间戳与数值对,表示一个指标在某个时间点上的监测值。
指标类型(Type):指标的类型,如counter、gauge等。
指标标签(Labels):对指标进行描述和区分的一组键值对标签。
指标注释(Help text):对指标的文字描述。
网友评论