Memcached Exporter 快速入门
Prometheus exporter for Memcached server metrics.
https://github.com/prometheus/memcached_exporter
memcached_exporter 从 memcached 服务器导出指标供 Prometheus 使用。服务器被指定
--memcached.address
为程序的标志(默认为localhost:11211
)。
一、部署 memcached_exporter
下载 memcached_exporter
https://github.com/prometheus/memcached_exporter/releases
解压并安装:
cd /usr/local/src && tar -zxvf memcached_exporter-0.11.2.linux-amd64.tar.gz;
mv memcached_exporter-0.11.2.linux-amd64 /usr/local/memcached_exporter;
cd /usr/local/memcached_exporter;
查看使用帮助:
[root@192 memcached_exporter]# ./memcached_exporter -h
usage: memcached_exporter [<flags>]
Flags:
-h, --[no-]help Show context-sensitive help (also try --help-long and --help-man).
--memcached.address="localhost:11211"
Memcached server address.
--memcached.timeout=1s memcached connect timeout.
--memcached.pid-file="" Optional path to a file containing the memcached PID for additional metrics.
--[no-]memcached.tls.enable
Enable TLS connections to memcached
--memcached.tls.cert-file=""
Client certificate file.
--memcached.tls.key-file=""
Client private key file.
--memcached.tls.ca-file=""
Client root CA file.
--[no-]memcached.tls.insecure-skip-verify
Skip server certificate verification
--memcached.tls.server-name=""
Memcached TLS certificate servername
--[no-]web.systemd-socket Use systemd socket activation listeners instead of port listeners (Linux only).
--web.listen-address=:9150 ...
Addresses on which to expose metrics and web interface. Repeatable for multiple addresses.
--web.config.file="" [EXPERIMENTAL] Path to configuration file that can enable TLS or authentication.
--web.telemetry-path="/metrics"
Path under which to expose metrics.
--log.level=info Only log messages with the given severity or above. One of: [debug, info, warn, error]
--log.format=logfmt Output format of log messages. One of: [logfmt, json]
--[no-]version Show application version.
默认情况下,memcache_exporter 在以下端口提供 0.0.0.0:9150
服务/metrics
:
./memcached_exporter
或者提供一个 Dockerfile:
docker run -p 9150:9150 quay.io/prometheus/memcached-exporter:latest
访问监控度量信息地址:
使用 systemd方式启动
# cat >/usr/lib/systemd/system/memcached_exporter.service <<EOF
[Unit]
Description=Prometheus exporter for Memcached server metrics.
Documentation=https://github.com/prometheus/memcached_exporter
After=network.target
[Service]
ExecStart=/usr/local/memcached_exporter/memcached_exporter --memcached.address=localhost:11211 --web.listen-address=:9150
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
# systemctl enable memcached_exporter
# systemctl restart memcached_exporter
# systemctl status memcached_exporter
设置随机启动:
[root@local ~]# systemctl daemon-reload
[root@local ~]# systemctl disable memcached_exporter.service
[root@local ~]# systemctl enable memcached_exporter.service
[root@local ~]# systemctl start memcached_exporter.service
[root@local ~]# systemctl status memcached_exporter.service
[root@local ~]# systemctl stop memcached_exporter.service
[root@local ~]# systemctl restart memcached_exporter.service
二、在 prometheus.yaml 中添加 memcached_exporter 的配置
在 Prometheus 配置文件里,您可以按如下方式设置抓取配置
- job_name: memcached # To get metrics about the memcached exporter’s targets
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9150"]
作者:Jeebiz 创建时间:2023-02-19 21:08
最后编辑:Jeebiz 更新时间:2024-01-24 21:48
最后编辑:Jeebiz 更新时间:2024-01-24 21:48