OpenStack Exporter安装
GitHub项目地址:https://github.com/openstack-exporter/openstack-exporter
OpenStack Exporter for Prometheus
使用docker安装
编写clouds.yaml
(默认 /etc/openstack/clouds.yaml )
官方案例:
clouds:
default:
region_name: {{ openstack_region_name }}
identity_api_version: 3
identity_interface: internal
auth:
username: {{ keystone_admin_user }}
password: {{ keystone_admin_password }}
project_name: {{ keystone_admin_project }}
project_domain_name: 'Default'
project_domain_id: 'Default' // This can replace "project_domain_name"
user_domain_name: 'Default'
auth_url: {{ admin_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}/v3
cacert: |
---- BEGIN CERTIFICATE ---
...
verify: true | false // disable || enable SSL certificate verification
clouds:
default:
region_name: RegionOne
interface: public
identity_api_version: 3
auth:
auth_url: http://controller/v3
username: admin
password: 000000
project_name: admin
user_domain_name: 'Default'
project_domain_name: 'Default'
verify: true
Command line options 命令行选项
当前的命令行选项列表(通过运行 --help)
usage: openstack-exporter [<flags>] [<cloud>]
Flags:
-h, --[no-]help Show context-sensitive help (also try --help-long and --help-man).
--web.telemetry-path="/metrics"
uri path to expose metrics
--os-client-config="/etc/openstack/clouds.yaml"
Path to the cloud configuration file
--prefix="openstack" Prefix for metrics
--endpoint-type="public" openstack endpoint type to use (i.e: public, internal, admin)
--[no-]collect-metric-time
time spent collecting each metric
-d, --disable-metric= ... multiple --disable-metric can be specified in the format: service-metric (i.e: cinder-snapshots)
--[no-]disable-slow-metrics
Disable slow metrics for performance reasons
--[no-]disable-deprecated-metrics
Disable deprecated metrics
--[no-]disable-cinder-agent-uuid
Disable UUID generation for Cinder agents
--[no-]multi-cloud Toggle the multiple cloud scraping mode under /probe?cloud=
--domain-id=DOMAIN-ID Gather metrics only for the given Domain ID (defaults to all domains)
--[no-]disable-service.network
Disable the network service exporter
--[no-]disable-service.compute
Disable the compute service exporter
--[no-]disable-service.image
Disable the image service exporter
--[no-]disable-service.volume
Disable the volume service exporter
--[no-]disable-service.identity
Disable the identity service exporter
--[no-]disable-service.object-store
Disable the object-store service exporter
--[no-]disable-service.load-balancer
Disable the load-balancer service exporter
--[no-]disable-service.container-infra
Disable the container-infra service exporter
--[no-]disable-service.dns
Disable the dns service exporter
--[no-]disable-service.baremetal
Disable the baremetal service exporter
--[no-]disable-service.gnocchi
Disable the gnocchi service exporter
--[no-]disable-service.database
Disable the database service exporter
--[no-]disable-service.orchestration
Disable the orchestration service exporter
--[no-]disable-service.placement
Disable the placement service exporter
--[no-]web.systemd-socket Use systemd socket activation listeners instead of port listeners (Linux only).
--web.listen-address=:9180 ...
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. See:
https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md
--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.
Args:
[<cloud>] name or id of the cloud to gather metrics from
在controller控制节点执行:
docker run -v /etc/openstack/clouds.yaml:/etc/openstack/clouds.yaml -it -p 9180:9180 ghcr.io/openstack-exporter/openstack-exporter:latest --prefix="openstack" --endpoint-type="public" default
在执行后出现报错情况
exporter在收集OpenStack的指标时无法解析controller
主机名,导致无法连接到OpenStack服务。错误信息多次提到dial tcp: lookup controller on 8.8.8.8:53: no such host
,这意味着DNS解析失败,无法找到名为controller
的主机。
日志中的错误是因为找不到合适的服务端点导致的。baremetal, gnocchi, orchestration服务的出口程序无法启用,因为在服务目录中找不到适当的端点。可以选择直接关闭掉。
修改后的命令:
–add-host controller:<控制节点的IP地址> ,
–disable-service.<日志中不需要的服务名称 >
docker run -v /etc/openstack/clouds.yaml:/etc/openstack/clouds.yaml --add-host controller:192.100.10.10 -it -p 9180:9180 ghcr.io/openstack-exporter/openstack-exporter:latest --disable-service.load-balancer --disable-service.orchestration --disable-service.object-store --disable-service.dns --disable-service.gnocchi --disable-service.database --disable-service.container-infra --disable-service.baremetal --prefix="openstack" --endpoint-type="public" default
修改prometheus配置文件,添加openstack_exporter参数, 修改完后重启prometheus .
/prometheus $ vi /etc/prometheus/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).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets: ['172.5.3.10:9093']
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
- "node_down.yml"
# - "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'
static_configs:
- targets: ['localhost:9090']
- job_name: 'openstack_exporter'
scrape_interval: 5s
static_configs:
- targets:
- '172.5.3.10:9180'
Prometheus成功读取无报错
Prometheus对接Grafana
- 添加Prometheus数据源
- 添加仪表盘
- 导入仪表盘 ( ID:9701 )
面板数据正常显示