Skip to content

Instantly share code, notes, and snippets.

@vanduc95
Last active July 16, 2022 00:17
Show Gist options
  • Save vanduc95/9b2ddff70c1e2a15db0d1e47b1fce1c1 to your computer and use it in GitHub Desktop.
Save vanduc95/9b2ddff70c1e2a15db0d1e47b1fce1c1 to your computer and use it in GitHub Desktop.

Install Ceilometer + Gnocchi with backend Ceph

In Controller node

  • Create database
mysql -uroot -pWelcome123

CREATE DATABASE gnocchi;
GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'localhost' IDENTIFIED BY 'Welcome123' WITH GRANT OPTION ;
GRANT ALL PRIVILEGES ON gnocchi.* TO 'gnocchi'@'%' IDENTIFIED BY 'Welcome123' WITH GRANT OPTION ;
FLUSH PRIVILEGES;
  • Create the service credentials, endpoint.
#192.168.20.14: ip node ceilometer

. admin.sh

openstack user create ceilometer --domain default --password Welcome123
openstack role add --project service --user ceilometer admin
openstack service create --name ceilometer --description "Telemetry" metering

openstack user create gnocchi --domain default --password Welcome123
openstack role add --project service --user gnocchi admin
openstack service create --name gnocchi --description "OpenStack Metric" metric

openstack endpoint create --region RegionOne metric public http://192.168.20.14:8041
openstack endpoint create --region RegionOne metric internal http://192.168.20.14:8041
openstack endpoint create --region RegionOne metric admin http://192.168.20.14:8041

In Compute node (collect metric instances)

  • install package
apt-get -y install ceilometer-agent-compute
  • Edit file /etc/ceilometer/ceilometer.conf
[DEFAULT]
transport_url = rabbit://openstack:Welcome123@controller
log_dir = /var/log/ceilometer

[service_credentials]
auth_uri = http://controller:5000/v3
auth_url = http://controller:35357/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = Welcome123
interface = internalURL
region_name = RegionOne
  • Edit file /etc/nova/nova.conf
[DEFAULT]
...
instance_usage_audit True
instance_usage_audit_period hour
notify_on_state_change vm_and_task_state

[oslo_messaging_notifications]
...
driver = messagingv2
  • Restart the agent and Compute service
service ceilometer-agent-compute restart
service nova-compute restart

In Ceilometer node

Install and config gnocchi

  • Edit file hosts
10.10.0.160 controller
10.10.0.161 compute1

  • Install packages
apt-get install -y gnocchi-api gnocchi-common gnocchi-metricd python-gnocchiclient python-pymemcache

  • Edit file /etc/gnocchi/gnocchi.conf
[DEFAULT]
log_dir = /var/log/gnocchi
transport_url = rabbit://openstack:Welcome123@controller

[api]
paste_config = /etc/gnocchi/api-paste.ini
auth_mode = keystone

[archive_policy]
default_aggregation_methods = mean,min,max,sum,std,median,count,last,95pct

[database]
backend = sqlalchemy

[indexer]
url = mysql+pymysql://gnocchi:Welcome123@controller/gnocchi
driver = sqlalchemy

[keystone_authtoken]
auth_uri = http://controller:5000/v3
auth_url = http://controller:35357/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = gnocchi
password = Welcome123
interface = internalURL
region_name = RegionOne
auth_version = 3
auth_port = 35357

[metricd]
workers = 6
metric_processing_delay = 5

[storage]
## Use Ceph
driver = ceph
ceph_pool = gnocchi
ceph_username = gnocchi
ceph_keyring = /etc/ceph/ceph.client.gnocchi.keyring
ceph_conffile = /etc/ceph/ceph.conf

## Use file 
#driver = file
#file_basepath = /var/lib/gnocchi
#coordination_url = file:///var/lib/gnocchi/locks

  • Edit file /etc/gnocchi/api-paste.ini
# ...
[pipeline:main]
pipeline = gnocchi+auth

  • Gnocchi upgrade
chown gnocchi:gnocchi -R  /var/lib/gnocchi

su gnocchi -s /bin/sh -c 'gnocchi-upgrade --config-file /etc/gnocchi/gnocchi.conf --create-legacy-resource-types'
  • Edit file /etc/apache2/sites-available/gnocchi-api.conf
Listen 8041

<VirtualHost *:8041>
    WSGIDaemonProcess gnocchi-api processes=2 threads=10 user=gnocchi display-name=%{GROUP}
    WSGIProcessGroup gnocchi-api
    WSGIScriptAlias / /usr/lib/python2.7/dist-packages/gnocchi/rest/app.wsgi
    WSGIApplicationGroup %{GLOBAL}
    <IfVersion >= 2.4>
        ErrorLogFormat "%{cu}t %M"
    </IfVersion>

    <Directory />
        Options FollowSymLinks
        AllowOverride None
        <IfVersion >= 2.4>
            Require all granted
        </IfVersion>
        <IfVersion < 2.4>
            Order allow,deny
            Allow from all
        </IfVersion>
    </Directory>

    ErrorLog /var/log/apache2/gnocchi_error.log
    CustomLog /var/log/apache2/gnocchi_access.log combined
</VirtualHost>
WSGISocketPrefix /var/run/apache2
  • Change port gnocchi and restart service
sed -i 's/8000/8041/g' /usr/bin/gnocchi-api

service apache2 restart
service gnocchi-metricd restart
  • Create adminrc. Note: add environment OS_AUTH_TYPE=password
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=Welcome123
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export OS_AUTH_TYPE=password
  • Test gnocchi
# gnocchi status
+-----------------------------------------------------+-------+
| Field                                               | Value |
+-----------------------------------------------------+-------+
| storage/number of metric having measures to process | 0     |
| storage/total number of measures to process         | 0     |
+-----------------------------------------------------+-------+

Install and config Ceilometer

  • Install packages
apt-get install -y ceilometer-agent-notification ceilometer-agent-central python-ceilometerclient
  • Edit file /etc/ceilometer/ceilometer.conf
[DEFAULT]
meter_dispatchers = gnocchi
event_dispatchers = gnocchi
transport_url = rabbit://openstack:Welcome123@controller


[dispatcher_gnocchi]
filter_service_activity = False
archive_policy = high

[keystone_authtoken]
auth_uri = http://controller:5000/v3
auth_url = http://controller:35357/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = gnocchi
password = Welcome123
interface = internalURL
region_name = RegionOne

[service_credentials]
auth_uri = http://controller:5000/v3
auth_url = http://controller:35357/v3
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = ceilometer
password = Welcome123
interface = internalURL
region_name = RegionOne
  • Ceilometer upgrade and restart service
ceilometer-upgrade --skip-metering-database

service ceilometer-agent-central restart
service ceilometer-agent-notification restart

Cấu hình Grafana lấy metric từ Gnocchi

  • In Grafana node, instal Gnocchi Datasource:
sudo grafana-cli plugins install gnocchixyz-gnocchi-datasource
service grafana-server restart
  • Grafana has 2 modes of operation: proxy or direct mode.
    • proxy: ở mode nĂ y, Grafana sẽ nhận request từ user, vĂ chuyển tá»›i Gnocchi. Grafana sẽ chỉ xĂ¡c thá»±c được vá»›i Gnocchi qua token được cung cấp sẵn, khi token hết hạn sẽ phải cấp lại, hoặc lá»±a chá»�n khĂ´ng xĂ¡c thá»±c Gnocchi vá»›i Keystone (kĂ©m bảo mật).

    • direct: ở mode nĂ y, user sẽ lĂ m việc trá»±c tiếp vá»›i Gnocchi, Grafana chỉ Ä‘Ă³ng vai trĂ² hiển thi. User sẽ xĂ¡c thá»±c vá»›i Keystone định kỳ, do Ä‘Ă³ bảo mật được thĂ´ng tin.

Use proxy mode

  • Configure a new datasource in Grafana with the Gnocchi URL. If you are using the Keystone middleware for authentication, you can also provide an authentication token.

enter image description here

(192.168.20.14: ip Gnocchi node)

Use direct mode

  • Configure the CORS middleware in file /etc/gnocchi/gnocchi.conf in Gnocchi node to allow request from Grafana.
[cors]
allowed_origin = http://192.168.10.170:3000 
  • Restart apache2
service apache2 restart
  • Configure the CORS middleware in file /etc/keystone/keystone.conf in Controller node to allow request from Grafana too:
[cors]
allowed_origin = http://192.168.10.170:3000
  • Restart apache2
service apache2 restart

enter image description here

Reference

https://docs.openstack.org/ceilometer/pike/index.html

https://jtechboard.blogspot.com/2017/10/openstack-monitoring-using-ceilometer.html

https://adhioutlined.github.io/virtual/Installing-gnocchi-ceilometer-openstack-ocata-xenserver/

http://gnocchi.xyz/grafana.html

@adouni1104
Copy link

hi nice work I did your steps but I get this error when I run gnocchi status :

root@controller:~# gnocchi status

<title>404 Not Found</title>

Not Found

The requested URL /v1/status was not found on this server.


Apache/2.4.18 (Ubuntu) Server at localhost Port 8041 (HTTP 404)

I am using openstack queens on Ubuntu 16.04 !! it will be nice if can help me with this

@wahab-icp
Copy link

Hello @adouni1104 and @vanduc95,
I am getting the same error, any solutions please?

<title>404 Not Found</title>

Not Found

The requested URL /v1/resource/image was not found on this server.


Apache/2.4.29 (Ubuntu) Server at localhost Port 8041 (HTTP 404)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment