一、Controller节点配置gnocchi
root@controller-01:~# mysqlCREATE DATABASE gnocchi;GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' IDENTIFIED BY 'GNOCCHI_DBPASS';GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' IDENTIFIED BY 'GNOCCHI_DBPASS';
openstack user create --domain default --password CEILOMETER ceilometeropenstack role add --project service --user ceilometer adminopenstack user create --domain default --password GNOCCHI gnocchiopenstack role add --project service --user gnocchi admin
openstack service create --name ceilometer --description "Telemetry" meteringopenstack service create --name gnocchi --description "Metric Service" metric
openstack endpoint create --region RegionOne metric public http://controller:8041openstack endpoint create --region RegionOne metric internal http://controller:8041openstack endpoint create --region RegionOne metric admin http://controller:8041
1.5 安装配置redis服务
1.5.1 安装redis
apt -y install redis
1.5.2 配置redis
root@controller-01:~# cat etc/redis/redis.conf | egrep -v "^$|^#"bind 0.0.0.0 ::1protected-mode noport 6379tcp-backlog 511timeout 0tcp-keepalive 300daemonize yessupervised nopidfile var/run/redis/redis-server.pidloglevel noticelogfile var/log/redis/redis-server.logdatabases 16always-show-logo yessave 900 1save 300 10save 60 10000stop-writes-on-bgsave-error yesrdbcompression yesrdbchecksum yesdbfilename dump.rdbdir var/lib/redisslave-serve-stale-data yesslave-read-only yesrepl-diskless-sync norepl-diskless-sync-delay 5repl-disable-tcp-nodelay noslave-priority 100lazyfree-lazy-eviction nolazyfree-lazy-expire nolazyfree-lazy-server-del noslave-lazy-flush noappendonly noappendfilename "appendonly.aof"appendfsync everysecno-appendfsync-on-rewrite noauto-aof-rewrite-percentage 100auto-aof-rewrite-min-size 64mbaof-load-truncated yesaof-use-rdb-preamble nolua-time-limit 5000slowlog-log-slower-than 10000slowlog-max-len 128latency-monitor-threshold 0notify-keyspace-events ""hash-max-ziplist-entries 512hash-max-ziplist-value 64list-max-ziplist-size -2list-compress-depth 0set-max-intset-entries 512zset-max-ziplist-entries 128zset-max-ziplist-value 64hll-sparse-max-bytes 3000activerehashing yesclient-output-buffer-limit normal 0 0 0client-output-buffer-limit slave 256mb 64mb 60client-output-buffer-limit pubsub 32mb 8mb 60hz 10aof-rewrite-incremental-fsync yes
root@controller-01:~# redis-server etc/redis/redis.conf
1.6 安装uwsgi模块
root@controller-01:~# apt install uwsgi-plugin-python3 uwsgi
TIPs:不安装uwsgi模块时,否者会报错;
root@controller-01:~# usr/bin/gnocchi-api2021-03-08 02:22:17,727 [13171] INFO gnocchi.service: Gnocchi version 4.3.22021-03-08 02:22:17,733 [13171] ERROR gnocchi.cli.api: Unable to find `uwsgi'.Be sure it is installed and in $PATH.
apt-get install gnocchi-api gnocchi-metricd python3-gnocchiclientecho "export OS_AUTH_TYPE=password" >> root/admin-openrc#否者报错root@controller-01:~# gnocchi metric listThe request you have made requires authentication. (HTTP 401)
[root@openstack-controller ~]# grep "OS_AUTH_TYPE" /usr/lib/python2.7/site-packages/gnocchiclient/shell.pyos.environ["OS_AUTH_TYPE"]= "password"#os.environ.set("OS_AUTH_TYPE", "password")[root@openstack-controller ~]# gnocchi-upgrade2021-01-22 15:03:39,365 [20889] INFO gnocchi.service: Gnocchi version 4.3.42021-01-22 15:03:40,067 [20889] INFO gnocchi.cli.manage: Upgrading indexer SQLAlchemyIndexer: mysql+pymysql://***:***@controller/gnocchi2021-01-22 15:03:40,231 [20889] INFO gnocchi.cli.manage: Upgrading storage FileStorage: var/lib/gnocchi2021-01-22 15:03:40,242 [20889] INFO gnocchi.cli.manage: Upgrading incoming storage FileStorage: /var/lib/gnocchi
1.7.3 配置gnocchi服务
root@controller-01:~# cat etc/gnocchi/gnocchi.conf | egrep -v "^$|^#"[DEFAULT]debug = trueverbose = truelog_dir = var/log/gnocchiparallel_operations = 4coordination_url = redis://controller:6379[api]auth_mode = keystonehost = controllerport = 8041uwsgi_mode = http-socketmax_limit = 1000[archive_policy]default_aggregation_methods = mean,min,max,sum,std,count[cors]allowed_origin = http://controller:3000[healthcheck][incoming][indexer]url = mysql+pymysql://gnocchi:GNOCCHI_DBPASS@controller/gnocchi[keystone_authtoken]region_name = RegionOnewww_authenticate_uri = http://controller:5000auth_url = http://controller:5000/v3memcached_servers = controller:11211auth_type = passwordproject_domain_name = defaultuser_domain_name = defaultproject_name = serviceusername = gnocchipassword = GNOCCHIservice_token_roles_required = trueauth_uri = http://controller:5000/v3[metricd]workers = 4metric_processing_delay = 60greedy = truemetric_reporting_delay = 120metric_cleanup_delay = 300[oslo_middleware][oslo_policy][statsd][storage]coordination_url = redis://controller:6379file_basepath = var/lib/gnocchidriver = file
1.7.4 初始化gnocchi
root@controller-01:~# gnocchi-upgrade2021-03-08 02:05:47,559 [10873] INFO gnocchi.service: Gnocchi version 4.3.22021-03-08 02:05:48,019 [10873] INFO gnocchi.cli.manage: Upgrading indexer SQLAlchemyIndexer: mysql+pymysql://gnocchi:GNOCCHI_DBPASS@controller/gnocchi2021-03-08 02:05:48,137 [10873] INFO gnocchi.cli.manage: Upgrading storage FileStorage: var/lib/gnocchi2021-03-08 02:05:48,141 [10873] INFO gnocchi.cli.manage: Upgrading incoming storage FileStorage: var/lib/gnocchi
1.7.5 启动gnocchi服务
TIPs:由于openstack stein版本的gnocchi组件存在bug,apt安装程序之后没有gnocchi.service文件,需要手动添加。
root@controller-01:~# cat lib/systemd/system/gnocchi-api.service[Unit]Description=Gnocchi API serviceAfter=syslog.target network.target[Service]Type=simpleUser=gnocchiExecStart=/usr/bin/gnocchi-api -- --log-file var/log/gnocchi/api.logRestart=on-failure[Install]WantedBy=multi-user.target
systemctl restart gnocchi-api.service gnocchi-metricd.service
二、安装ceilometer组件
2.1 安装配置ceilometer-agent-notification、ceilometer-agent-central组件
apt-get install ceilometer-agent-notification ceilometer-agent-central
root@controller-01:~# cat etc/ceilometer/ceilometer.conf | egrep -v "^#|^$"[DEFAULT]debug = trueauth_strategy = keystonetransport_url = rabbit://openstack:RABBIT_PASS@controllerpipeline_cfg_file = pipeline.yaml[compute][coordination][event][hardware][ipmi][meter][notification]store_events = truemessaging_urls = rabbit://openstack:RABBIT_PASS@controller[oslo_concurrency][oslo_messaging_amqp][oslo_messaging_kafka][oslo_messaging_notifications][oslo_messaging_rabbit][polling]cfg_file = polling.yaml[publisher][publisher_notifier][rgw_admin_credentials][rgw_client][service_credentials]auth_type = passwordauth_url = http://controller:5000/v3project_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = ceilometerpassword = CEILOMETERinterface = internalURLregion_name = RegionOne[service_types][vmware][xenapi]
2.2 在Gnocchi生成ceilometer资源
root@controller-01:~# chmod 777 var/log/gnocchi/gnocchi-api.logroot@controller-01:~# ceilometer-upgrade
2.3 启动ceilometer
service ceilometer-agent-central restartservice ceilometer-agent-notification restart
2.4 配置glance使用ceilometer服务(glance-api.conf)
[DEFAULT]transport_url = rabbit://openstack:RABBIT_PASS@controller[oslo_messaging_notifications]driver = messagingv2
service glance-api restart
2.5 配置neutron使用ceilometer服务(neutron.conf)
[oslo_messaging_notifications]driver = messagingv2
service neutron-server restart
三、Compute节点配置
3.1 安装配置ceilometer
3.1.1 安装ceilometer服务
apt-get install ceilometer-agent-compute
3.1.2 配置ceilometer服务
root@compute-01:~# cat etc/ceilometer/ceilometer.conf | egrep -v "^$|^#"[DEFAULT]transport_url = rabbit://openstack:RABBIT_PASS@controller[compute][coordination][event][hardware][ipmi][meter][notification][oslo_concurrency][oslo_messaging_amqp][oslo_messaging_kafka][oslo_messaging_notifications][oslo_messaging_rabbit][polling][publisher][publisher_notifier][rgw_admin_credentials][rgw_client][service_credentials]auth_type = passwordauth_url = http://controller:5000/v3project_domain_id = defaultuser_domain_id = defaultproject_name = serviceusername = ceilometerpassword = CEILOMETERinterface = internalURLregion_name = RegionOne[service_types][vmware][xenapi]
3.2 配置nova使用ceilometer
[DEFAULT]instance_usage_audit = Trueinstance_usage_audit_period = hour[notifications]notify_on_state_change = vm_and_task_state[oslo_messaging_notifications]driver = messagingv2
3.3 启动服务
service ceilometer-agent-compute restartservice nova-compute restart
四、配置Hardware meter
https://ask.openstack.org/en/question/105993/how-to-enable-hardware-metrics-on-gnocchi/
4.1 controller与compute安装snmp
apt install snmp*
4.2 snmp配置文件
root@controller-01:~# cat etc/snmp/snmpd.conf | egrep -v "^$|^#"agentAddress udp:161,udp6:[::1]:161view systemonly included .1.3.6.1.4.1.2021.4view systemonly included .1.3.6.1.4.1.2021.11view systemonly included .1.3.6.1.2.1.2.2.1rocommunity public localhostrocommunity public default -V systemonlyrocommunity6 public default -V systemonlycom2sec OS_net_sec 10.50.0.0/24 OS_communitygroup OS_Group any OS_net_secview OS_view included .1 80access OS_Group "" any noauth 0 OS_view none nonerouser authOnlyUserproc mountd# No more than 4 'ntalkd' processes - 0 is OKproc ntalkd 4# At least one 'sendmail' process, but no more than 10proc sendmail 10 1disk / 10000disk /var 5%includeAllDisks 10%load 12 10 5trapsink 10.50.0.6 publiciquerySecName internalUserrouser internalUserdefaultMonitors yeslinkUpDownNotifications yesextend test1 /bin/echo Hello, world!extend-sh test2 echo Hello, world! ; echo Hi there ; exit 35master agentxroot@controller-01:~# cat /etc/snmp/snmp.conf# As the snmp packages come without MIB files due to license reasons, loading# of MIBs is disabled by default. If you added the MIBs you can reenable# loading them by commenting out the following line.#mibs :
4.3 测试snmp
root@controller-01:~# snmpwalk -v 2c -c public 172.17.61.22 memTotalReal.0UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 8167644 kBroot@controller-01:~# snmpwalk -v 2c -c public localhost .1.3.6.1.4.1.2021.4.3.0UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 4194300 kB
4.4 pipeline.yaml
root@controller-01:~# cat /etc/ceilometer/pipeline.yaml---sources:- name: meter_sourcemeters:- "*"sinks:- meter_sink- name: cpu_sourcemeters:- "cpu"sinks:- cpu_sink- cpu_delta_sink- name: disk_sourcemeters:- "disk.read.bytes"- "disk.read.requests"- "disk.write.bytes"- "disk.write.requests"- "disk.device.read.bytes"- "disk.device.read.requests"- "disk.device.write.bytes"- "disk.device.write.requests"sinks:- disk_sink- name: network_sourcemeters:- "network.incoming.bytes"- "network.incoming.packets"- "network.outgoing.bytes"- "network.outgoing.packets"sinks:- network_sink- name: snmp_hardware_hostresources:- snmp://public@172.17.61.22- snmp://public@172.17.61.26meters:- "hardware.cpu.util"- "hardware.memory.used"sinks:- meter_snmp_hostsinks:- name: meter_sinktransformers:publishers:- gnocchi://- name: meter_snmp_hosttransformers:publishers:- gnocchi://- name: cpu_sinktransformers:- name: "rate_of_change"parameters:target:name: "cpu_util"unit: "%"type: "gauge"max: 100scale: "100.0 / (10**9 * (resource_metadata.cpu_number or 1))"publishers:- gnocchi://- name: cpu_delta_sinktransformers:- name: "delta"parameters:target:name: "cpu.delta"growth_only: Truepublishers:- gnocchi://- name: disk_sinktransformers:- name: "rate_of_change"parameters:source:map_from:name: "(disk\\.device|disk)\\.(read|write)\\.(bytes|requests)"unit: "(B|request)"target:map_to:name: "\\1.\\2.\\3.rate"unit: "\\1/s"type: "gauge"publishers:- gnocchi://- name: network_sinktransformers:- name: "rate_of_change"parameters:source:map_from:name: "network\\.(incoming|outgoing)\\.(bytes|packets)"unit: "(B|packet)"target:map_to:name: "network.\\1.\\2.rate"unit: "\\1/s"type: "gauge"publishers:- gnocchi://
4.5 polling.yaml
root@controller-01:~# cat /etc/ceilometer/polling.yaml---sources:- name: some_pollstersresources:- snmp://public@172.17.61.22- snmp://public@172.17.61.26interval: 300meters:- cpu- cpu_l3_cache- memory.usage- network.incoming.bytes- network.incoming.packets- network.outgoing.bytes- network.outgoing.packets- disk.device.read.bytes- disk.device.read.requests- disk.device.write.bytes- disk.device.write.requests- hardware.cpu.util- hardware.cpu.user- hardware.cpu.nice- hardware.cpu.system- hardware.cpu.idle- hardware.cpu.wait- hardware.cpu.kernel- hardware.cpu.interrupt- hardware.memory.used- hardware.memory.total- hardware.memory.buffer- hardware.memory.cached- hardware.memory.swap.avail- hardware.memory.swap.total- hardware.system_stats.io.outgoing.blocks- hardware.system_stats.io.incoming.blocks- hardware.network.ip.incoming.datagrams- hardware.network.ip.outgoing.datagrams
五、测试ceilometer(gnocchi-cli)
resource:资源大类,比如实例、hardware、network等等;
metric:某资源类中可以收集监控的度量;
measures:某个具体度量的取值;
pipeline.yaml:定义resource、metric以及输出数据到gnocchi或者其他;
polling.yaml:定义哪些resource、metric来轮询;
https://docs.openstack.org/ocata/cli-reference/gnocchi.html
5.1 查看gnocchi 状态
root@controller-01:~# gnocchi status+-----------------------------------------------------+-------+| Field | Value |+-----------------------------------------------------+-------+| storage/number of metric having measures to process | 9 || storage/total number of measures to process | 19 |+-----------------------------------------------------+-------+
5.2 列出所有metric
root@controller-01:~# gnocchi metric list+--------------------------------------+---------------------+--------------------------------------------+---------+--------------------------------------+| id | archive_policy/name | name | unit | resource_id |+--------------------------------------+---------------------+--------------------------------------------+---------+--------------------------------------+| 0bf17d5b-ffe7-4f0b-89a5-152da084f450 | ceilometer-low | hardware.memory.used | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || 0c092e5e-d979-4093-a055-437a12b77366 | ceilometer-low | disk.root.size | GB | e76f1e79-b056-4a39-9e03-5779c51f3593 || 1331becd-7efe-4909-b08d-73af449bb6fc | ceilometer-low | vcpus | vcpu | e76f1e79-b056-4a39-9e03-5779c51f3593 || 1373fa33-c629-4d7f-a3c0-2218029bbd25 | ceilometer-low-rate | hardware.cpu.system | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || 14d9d597-afb6-4b07-b9b5-4fd5a3cac2c7 | ceilometer-low | volume.provider.capacity.total | GB | dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 || 1b8955bc-a0e7-49ba-98b8-e4b1685f0939 | ceilometer-low | volume.provider.pool.capacity.total | GB | d231bc8e-dd6d-5691-b02d-54b4f26f8030 || 204e957a-65f7-436f-94b0-407d83751c4a | ceilometer-low | hardware.system_stats.io.incoming.blocks | blocks | 8fc85372-63c3-539f-ba7f-af092e3387ee || 215aaff7-0f15-4d50-87b2-3483d8bc3bad | ceilometer-low | volume.provider.capacity.free | GB | dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 || 25256da6-c761-471f-b41c-bb3560125461 | ceilometer-low | volume.provider.capacity.virtual_free | GB | dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 || 34659060-abc4-4555-8237-3769af593cdd | ceilometer-low | hardware.memory.total | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || 3eb1a853-8155-4dca-8680-f79d438df708 | ceilometer-low | hardware.memory.swap.avail | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || 40796e67-5724-4f64-b2cc-220f2d4c090e | ceilometer-low | volume.provider.pool.capacity.free | GB | d231bc8e-dd6d-5691-b02d-54b4f26f8030 || 40aaf318-40b8-4b49-b96b-7083a350ed49 | ceilometer-low-rate | network.outgoing.bytes | B | 7dec8750-64eb-5352-89cc-4c4e0e2979bd || 4d8161ac-8623-4644-b5da-8466b7147752 | ceilometer-low | hardware.memory.swap.total | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || 4df4e486-ec1b-479e-b2dc-1c019e235b63 | ceilometer-low-rate | network.outgoing.packets | packet | 7dec8750-64eb-5352-89cc-4c4e0e2979bd || 54ab7884-1c0f-4b91-9a95-dbbecc6b3e95 | ceilometer-low | volume.provider.capacity.allocated | GB | dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 || 64a4fcec-502f-4943-a203-fb25d5c1c414 | ceilometer-low-rate | disk.device.write.bytes | B | 7966c542-a7fd-5702-9dce-8916ec6309f6 || 6a8541b0-a364-490f-800f-56e7d61852ae | ceilometer-low | volume.provider.pool.capacity.allocated | GB | d231bc8e-dd6d-5691-b02d-54b4f26f8030 || 6c24fdf3-e2fa-4637-a481-2ba350a1a50a | ceilometer-low | volume.provider.pool.capacity.provisioned | GB | d231bc8e-dd6d-5691-b02d-54b4f26f8030 || 6daf7eda-3c2b-4683-9de4-4b151fe1f7a1 | ceilometer-low | volume.provider.capacity.provisioned | GB | dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 || 6f23ef0d-cb03-4f6b-89c7-281a99da4114 | ceilometer-low-rate | hardware.cpu.nice | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || 72066fd8-f058-4640-906c-f45dcc452e7b | ceilometer-low-rate | cpu | ns | e76f1e79-b056-4a39-9e03-5779c51f3593 || 72de0514-8b0e-41da-b8de-5cbeeb4a655f | ceilometer-low-rate | hardware.cpu.kernel | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || 749e3c56-3d12-4c51-a3ed-36af9bedf491 | ceilometer-low-rate | hardware.cpu.user | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || 794cc9c7-4d7c-4b29-ac52-0838da279bbd | ceilometer-low-rate | hardware.cpu.interrupt | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || 798e785f-3044-4e16-be6c-f7d4d547b16d | ceilometer-low-rate | disk.device.read.bytes | B | 7966c542-a7fd-5702-9dce-8916ec6309f6 || 9d1c2fd5-9f99-4475-aa9b-5b6023dcfe5f | ceilometer-low | volume.provider.pool.capacity.virtual_free | GB | d231bc8e-dd6d-5691-b02d-54b4f26f8030 || b5209cb2-44c3-4ba2-bf0a-c41e1af59998 | ceilometer-low-rate | hardware.cpu.wait | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || b85658b6-85a0-4dc5-b5d1-26354235805d | ceilometer-low-rate | hardware.cpu.idle | tick | 8fc85372-63c3-539f-ba7f-af092e3387ee || c054167f-ac5e-421a-972d-e5b370a90964 | ceilometer-low | memory | MB | e76f1e79-b056-4a39-9e03-5779c51f3593 || c9f79644-2d10-4c9b-aca8-80aa62423fc6 | ceilometer-low | hardware.system_stats.io.outgoing.blocks | blocks | 8fc85372-63c3-539f-ba7f-af092e3387ee || cb18ac4e-1cce-4b5b-b75f-8c1643ddb4d7 | ceilometer-low-rate | network.incoming.packets | packet | 7dec8750-64eb-5352-89cc-4c4e0e2979bd || cd7799c3-b0df-45ee-8b0e-7b8c1a3fc261 | ceilometer-low | disk.ephemeral.size | GB | e76f1e79-b056-4a39-9e03-5779c51f3593 || d0b594c9-24f7-4962-8d51-7befa14e1196 | ceilometer-low-rate | network.incoming.bytes | B | 7dec8750-64eb-5352-89cc-4c4e0e2979bd || d6afffae-dd08-4a8f-bc22-c207a2b107c1 | ceilometer-low | hardware.memory.cached | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || db96ba20-7441-4216-8e01-61ca34026209 | ceilometer-low | hardware.cpu.util | % | 8fc85372-63c3-539f-ba7f-af092e3387ee || ea96bc38-872c-475e-ad5a-2db3a946a39b | ceilometer-low | hardware.memory.buffer | KB | 8fc85372-63c3-539f-ba7f-af092e3387ee || ec6644fc-247a-4bae-979c-e3bf55151b16 | ceilometer-low-rate | disk.device.read.requests | request | 7966c542-a7fd-5702-9dce-8916ec6309f6 || fd3c549a-52a5-4c13-b96c-c0fc69addcd7 | ceilometer-low-rate | disk.device.write.requests | request | 7966c542-a7fd-5702-9dce-8916ec6309f6 |+--------------------------------------+---------------------+--------------------------------------------+---------+--------------------------------------+
5.3 列出所有resource
root@controller-01:~# gnocchi resource list+--------------------------------------+----------------------------+----------------------------------+----------------------------------+-----------------------------------------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+| id | type | project_id | user_id | original_resource_id | started_at | ended_at | revision_start | revision_end | creator |+--------------------------------------+----------------------------+----------------------------------+----------------------------------+-----------------------------------------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+| e76f1e79-b056-4a39-9e03-5779c51f3593 | instance | ded04e0f8ea5491582278519ce380edc | 6b2cb6a662404f40b02fa00364b70017 | e76f1e79-b056-4a39-9e03-5779c51f3593 | 2021-03-08T08:59:37.923321+00:00 | None | 2021-03-08T08:59:37.923349+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 || 7dec8750-64eb-5352-89cc-4c4e0e2979bd | instance_network_interface | ded04e0f8ea5491582278519ce380edc | 6b2cb6a662404f40b02fa00364b70017 | instance-00000004-e76f1e79-b056-4a39-9e03-5779c51f3593-tap586a5fbc-86 | 2021-03-08T09:04:27.556562+00:00 | None | 2021-03-08T09:04:27.556590+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 || 7966c542-a7fd-5702-9dce-8916ec6309f6 | instance_disk | ded04e0f8ea5491582278519ce380edc | 6b2cb6a662404f40b02fa00364b70017 | e76f1e79-b056-4a39-9e03-5779c51f3593-vda | 2021-03-08T09:04:27.595207+00:00 | None | 2021-03-08T09:04:27.595237+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 || 8fc85372-63c3-539f-ba7f-af092e3387ee | host | None | None | 172.17.61.22 | 2021-03-08T13:16:14.308275+00:00 | None | 2021-03-08T13:16:14.308304+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 || dbc19129-93e4-5eb5-b07b-96f0e3cf88a9 | volume_provider | None | None | blockstorage-01@lvm | 2021-03-09T04:50:09.594667+00:00 | None | 2021-03-09T04:50:09.594695+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 || d231bc8e-dd6d-5691-b02d-54b4f26f8030 | volume_provider_pool | None | None | blockstorage-01@lvm#LVM | 2021-03-09T04:50:09.596302+00:00 | None | 2021-03-09T04:50:09.596341+00:00 | None | e58c0df298594433aba87403d85e6926:f6faef563147458c8b96022029e33266 |+--------------------------------------+----------------------------+----------------------------------+----------------------------------+-----------------------------------------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+
5.4 列出resource-type
root@controller-01:~# gnocchi resource-type list+----------------------------+---------------------------------------------------------------------------------------+| name | attributes |+----------------------------+---------------------------------------------------------------------------------------+| ceph_account | || generic | || host | - host_name: type: string , required: True , max_length: 255 , min_length: 0 || host_disk | - host_name: type: string , required: True , max_length: 255 , min_length: 0 || | - device_name: type: string , required: False , max_length: 255 , min_length: 0 || host_network_interface | - host_name: type: string , required: True , max_length: 255 , min_length: 0 || | - device_name: type: string , required: False , max_length: 255 , min_length: 0 || identity | || image | - name: type: string , required: True , max_length: 255 , min_length: 0 || | - container_format: type: string , required: True , max_length: 255 , min_length: 0 || | - disk_format: type: string , required: True , max_length: 255 , min_length: 0 || instance | - flavor_id: type: string , required: True , max_length: 255 , min_length: 0 || | - image_ref: type: string , required: False , max_length: 255 , min_length: 0 || | - host: type: string , required: True , max_length: 255 , min_length: 0 || | - display_name: type: string , required: True , max_length: 255 , min_length: 0 || | - server_group: type: string , required: False , max_length: 255 , min_length: 0 || | - flavor_name: type: string , required: True , max_length: 255 , min_length: 0 || | - launched_at: type: datetime , required: False || | - created_at: type: datetime , required: False || | - deleted_at: type: datetime , required: False || instance_disk | - name: type: string , required: True , max_length: 255 , min_length: 0 || | - instance_id: type: uuid , required: True || instance_network_interface | - name: type: string , required: True , max_length: 255 , min_length: 0 || | - instance_id: type: uuid , required: True || ipmi | || ipmi_sensor | - node: type: string , required: True , max_length: 255 , min_length: 0 || loadbalancer | || manila_share | - name: type: string , required: False , max_length: 255 , min_length: 0 || | - host: type: string , required: True , max_length: 255 , min_length: 0 || | - protocol: type: string , required: False , max_length: 255 , min_length: 0 || | - availability_zone: type: string , required: False , max_length: 255 , min_length: 0 || | - status: type: string , required: True , max_length: 255 , min_length: 0 || network | || nova_compute | - host_name: type: string , required: True , max_length: 255 , min_length: 0 || port | - controller: type: string , required: True , max_length: 255 , min_length: 0 || stack | || swift_account | || switch | - controller: type: string , required: True , max_length: 255 , min_length: 0 || switch_port | - switch: type: string , required: True , max_length: 64 , min_length: 0 || | - port_number_on_switch: type: number , required: False , min: 0 , max: 4294967295 || | - neutron_port_id: type: string , required: False , max_length: 255 , min_length: 0 || | - controller: type: string , required: True , max_length: 255 , min_length: 0 || switch_table | - switch: type: string , required: True , max_length: 64 , min_length: 0 || | - controller: type: string , required: True , max_length: 255 , min_length: 0 || volume | - display_name: type: string , required: False , max_length: 255 , min_length: 0 || | - volume_type: type: string , required: False , max_length: 255 , min_length: 0 || | - image_id: type: uuid , required: False || | - instance_id: type: uuid , required: False || volume_provider | || volume_provider_pool | - provider: type: string , required: True , max_length: 255 , min_length: 0 |+----------------------------+---------------------------------------------------------------------------------------+
5.5 查看归档策略
root@controller-01:~# openstack metric archive-policy-rule list+---------+---------------------+----------------+| name | archive_policy_name | metric_pattern |+---------+---------------------+----------------+| default | low | * |+---------+---------------------+----------------+
5.6 查看instance相关的resource
root@controller-01:~# openstack server list+--------------------------------------+------+--------+--------------------------+---------------------+---------+| ID | Name | Status | Networks | Image | Flavor |+--------------------------------------+------+--------+--------------------------+---------------------+---------+| 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd | vm-3 | ACTIVE | selfservice=10.10.10.14 | cirros-0.3.0-x86_64 | m1.nano || 6583b3b0-96fd-45fa-bd75-fa7b0ae389e3 | vm-1 | ACTIVE | selfservice=10.10.10.130 | cirros-0.3.0-x86_64 | m1.nano || 9532719c-cbbe-472c-a77d-edc7052b1541 | vm-2 | ACTIVE | selfservice=10.10.10.33 | cirros-0.3.0-x86_64 | m1.nano |+--------------------------------------+------+--------+--------------------------+---------------------+---------+
root@controller-01:~# gnocchi resource list | grep 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd| 3e853cc3-8cc6-5fe8-99e6-9d79cbf8d8f5 | instance_network_interface | 15b1010426194e309cd8f3de6bf63e1a | 1d51703e805548d99cb35b0c3fb83a58 | instance-00000003-1deb9c8d-ca85-44d8-aa4d-5df648cc87bd-tapb974fcdc-dc | 2021-03-16T13:53:52.842660+00:00 | None | 2021-03-16T13:53:52.843133+00:00 | None | b6e6d99ddc9e4119b412c3a709b75ef9:d45795e7d1e54e0786ff9ef54ee0c226 || cd721f38-11c9-5ee0-b19a-35c87e311fb6 | instance_disk | 15b1010426194e309cd8f3de6bf63e1a | 1d51703e805548d99cb35b0c3fb83a58 | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd-vda | 2021-03-16T13:53:53.889809+00:00 | None | 2021-03-16T13:53:53.889838+00:00 | None | b6e6d99ddc9e4119b412c3a709b75ef9:d45795e7d1e54e0786ff9ef54ee0c226 || 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd | instance | 15b1010426194e309cd8f3de6bf63e1a | 1d51703e805548d99cb35b0c3fb83a58 | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd | 2021-03-16T13:50:38.306724+00:00 | None | 2021-03-16T14:00:42.055866+00:00 | None | b6e6d99ddc9e4119b412c3a709b75ef9:d45795e7d1e54e0786ff9ef54ee0c226 |
root@controller-01:~# gnocchi resource list --type host+--------------------------------------+------+------------+---------+----------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+----------------------------+| id | type | project_id | user_id | original_resource_id | started_at | ended_at | revision_start | revision_end | creator | host_name |+--------------------------------------+------+------------+---------+----------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+----------------------------+| 1a2adf48-6053-56c8-a072-267343026b09 | host | None | None | 172.17.61.22 | 2021-03-19T09:24:41.972881+00:00 | None | 2021-03-19T09:24:41.972911+00:00 | None | e6d0f62027aa4735983344073df086f0:f6faef563147458c8b96022029e33266 | snmp://public@172.17.61.22 |+--------------------------------------+------+------------+---------+----------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+----------------------------+
5.7 查看某一instance resource对应的所有metric
root@controller-01:~# gnocchi metric list | grep 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd| 2e2633ee-7b33-40a3-b42e-c02b40900df9 | ceilometer-low | disk.ephemeral.size | GB | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd || 35d85f55-104a-429f-97d1-58cbf4770e6f | ceilometer-low | memory | MB | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd || 4e9d0c8d-8abd-4ddf-96b5-81011236068b | ceilometer-low | disk.root.size | GB | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd || 52965e2b-a2ac-4f61-a987-e4c2dce8b5a8 | ceilometer-low | vcpus | vcpu | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd || 98be0dda-2bd3-4137-8255-cca16c052856 | ceilometer-low-rate | cpu | ns | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd || b297e8d3-a4bb-4148-bd03-e74f666de375 | ceilometer-low | compute.instance.booting.time | sec | 1deb9c8d-ca85-44d8-aa4d-5df648cc87bd |
5.8 查看某一instance resource对应的某一metric的measures值
root@controller-01:~# gnocchi measures show 52965e2b-a2ac-4f61-a987-e4c2dce8b5a8+---------------------------+-------------+-------+| timestamp | granularity | value |+---------------------------+-------------+-------+| 2021-03-16T22:15:00+08:00 | 300.0 | 1.0 || 2021-03-16T22:20:00+08:00 | 300.0 | 1.0 || 2021-03-16T23:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T00:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T01:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T02:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T04:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T05:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T06:00:00+08:00 | 300.0 | 1.0 || 2021-03-17T07:00:00+08:00 | 300.0 | 1.0 |+---------------------------+-------------+-------+root@controller-01:~# gnocchi measures show 35d85f55-104a-429f-97d1-58cbf4770e6f+---------------------------+-------------+-------+| timestamp | granularity | value |+---------------------------+-------------+-------+| 2021-03-16T22:15:00+08:00 | 300.0 | 64.0 || 2021-03-16T22:20:00+08:00 | 300.0 | 64.0 || 2021-03-16T23:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T00:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T01:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T02:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T04:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T05:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T06:00:00+08:00 | 300.0 | 64.0 || 2021-03-17T07:00:00+08:00 | 300.0 | 64.0 |+---------------------------+-------------+-------+
2021-03-16 22:17:54,509 [10492] INFO gnocchi.cli.metricd: 26 measurements bundles across 26 metrics wait to be processed.
root@controller-01:~# gnocchi resource create --type image --attribute disk_format:qcow2 -a container_format:bare -a name:cirros -n image:ceilometer-low -n image.size:ceilometer-low -n image.serve:ceilometer-low fd0bd450-d647-48d2-8498-88c9294c7501+-----------------------+-------------------------------------------------------------------+| Field | Value |+-----------------------+-------------------------------------------------------------------+| container_format | bare || created_by_project_id | ded04e0f8ea5491582278519ce380edc || created_by_user_id | 6b2cb6a662404f40b02fa00364b70017 || creator | 6b2cb6a662404f40b02fa00364b70017:ded04e0f8ea5491582278519ce380edc || disk_format | qcow2 || ended_at | None || id | fd0bd450-d647-48d2-8498-88c9294c7501 || metrics | image.serve: 1b12afdc-b52c-4eed-a162-f8b82bb2fd01 || | image.size: 0f500139-4262-40f6-b3b2-d94b8bdbda74 || | image: 2ebd649f-3610-4469-97a8-3085bf4a049b || name | cirros || original_resource_id | fd0bd450-d647-48d2-8498-88c9294c7501 || project_id | None || revision_end | None || revision_start | 2021-03-25T07:53:23.726143+00:00 || started_at | 2021-03-25T07:53:23.726119+00:00 || type | image || user_id | None |+-----------------------+-------------------------------------------------------------------+
root@controller-01:~# gnocchi resource list --type image+--------------------------------------+-------+------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+--------+------------------+-------------+| id | type | project_id | user_id | original_resource_id | started_at | ended_at | revision_start | revision_end | creator | name | container_format | disk_format |+--------------------------------------+-------+------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+--------+------------------+-------------+| fd0bd450-d647-48d2-8498-88c9294c7501 | image | None | None | fd0bd450-d647-48d2-8498-88c9294c7501 | 2021-03-25T07:53:23.726119+00:00 | None | 2021-03-25T07:53:23.726143+00:00 | None | 6b2cb6a662404f40b02fa00364b70017:ded04e0f8ea5491582278519ce380edc | cirros | bare | qcow2 |+--------------------------------------+-------+------------+---------+--------------------------------------+----------------------------------+----------+----------------------------------+--------------+-------------------------------------------------------------------+--------+------------------+-------------+
root@controller-01:~# gnocchi metric list | grep fd0bd450-d647-48d2-8498-88c9294c7501| 0f500139-4262-40f6-b3b2-d94b8bdbda74 | ceilometer-low | image.size | None | fd0bd450-d647-48d2-8498-88c9294c7501 || 1b12afdc-b52c-4eed-a162-f8b82bb2fd01 | ceilometer-low | image.serve | None | fd0bd450-d647-48d2-8498-88c9294c7501 || 2ebd649f-3610-4469-97a8-3085bf4a049b | ceilometer-low | image | None | fd0bd450-d647-48d2-8498-88c9294c7501 |
root@controller-01:~# gnocchi measures add --resource-id fd0bd450-d647-48d2-8498-88c9294c7501 --measure 2021-03-24T07:25:00+00:00@9761280 image.sizeroot@controller-01:~# gnocchi measures show 0f500139-4262-40f6-b3b2-d94b8bdbda74+---------------------------+-------------+-----------+| timestamp | granularity | value |+---------------------------+-------------+-----------+| 2021-03-24T15:25:00+08:00 | 300.0 | 9761280.0 |+---------------------------+-------------+-----------+
https://grafana.com/grafana/download?plcmt=footer
6.2 下载grafana deb程序包
sudo apt-get install -y adduser libfontconfig1wget https://dl.grafana.com/oss/release/grafana_6.4.3_amd64.debsudo dpkg -i grafana_6.4.3_amd64.deb
6.3 启动程序
root@controller-01:~# /bin/systemctl daemon-reloadroot@controller-01:~# /bin/systemctl enable grafana-serverroot@controller-01:~# /bin/systemctl start grafana-server
root@controller-01:~# grafana-cli plugins install gnocchixyz-gnocchi-datasourceinstalling gnocchixyz-gnocchi-datasource @ 1.7.0from: https://grafana.com/api/plugins/gnocchixyz-gnocchi-datasource/versions/1.7.0/downloadinto: /var/lib/grafana/plugins✔ Installed gnocchixyz-gnocchi-datasource successfullyRestart grafana after installing plugins . <service grafana-server restart>
[root@openstack-controller ~]# grafana-cli plugins install gnocchixyz-gnocchi-datasourceinstalling gnocchixyz-gnocchi-datasource @ 1.7.0from: https://grafana.com/api/plugins/gnocchixyz-gnocchi-datasource/versions/1.7.0/downloadinto: /var/lib/grafana/plugins✔ Installed gnocchixyz-gnocchi-datasource successfullyRestart grafana after installing plugins . <service grafana-server restart>
9.5 Dashboard添加数据源




https://grafana.com/grafana/dashboards?dataSource=gnocchixyz-gnocchi-datasource






