Prerequisites

PrerequisitesΒΆ

Before you add Gnocchi as a data source to Grafana, verify that your environment meets the following requirements.

  • Due to a limitation in Grafana, Gnocchi and Keystone must be accessible through the same HTTP vhost.
  • Keystone must return public endpoints for Gnocchi and for its own services.
  • The public endpoint must be resolvable from Grafana and your browser.
  • Cross-Origin Resource Sharing (CORS) must be enabled in Gnocchi and Keystone to allow requests from Grafana. Additionally, CORS must be enabled in your browser.

To satisfy the requirements, complete the following prerequisite steps:

  1. Enable CORS for the Gnocchi and Keystone servers:

    1. Open your project Git repository with the Reclass model on the cluster level.

    2. In the openstack/telemetry.yml file, add the following configuration for Gnocchi, specifying the vhost FQDN as allowed_origin:

      gnocchi:
        server:
          cors:
            allowed_origin: "http://example.com"
      
    3. In the openstack/control.yml file, add the following configuration for Keystone, specifying the vhost FQDN as allowed_origin:

      keystone:
        server:
          cors:
            allowed_origin: "http://example.com"
      
  2. Set the endpoints for Keystone and Gnocchi:

    1. In the openstack/init.yml file, specify the following parameters:

      _params:
          gnocchi_public_host: example.com
          gnocchi_public_port: 80
          gnocchi_public_path: '/metric'
          keystone_public_path: '/identity'
          keystone_public_address: example.com
          keystone_public_port: 80
      
  3. Log in to the Salt Master node.

  4. Apply the following states:

    salt 'ctl*' state.sls keystone
    salt -C 'I@keystone:client' state.sls keystone.client
    salt 'mdb*' state.sls gnocchi
    
  5. Configure the same HTTP host for Gnocchi and Keystone:

    1. Create a new file /etc/nginx/sites-enabled/nginx_proxy_gnocchi.conf for the vhost configuration for Gnocchi and specify the following parameters:

      server {
          listen 80 default_server;
          server_name _;
      
          location ~ ^/metric/?(.*) {
              proxy_pass      http://172.16.10.250:8041/$1;
      
              proxy_pass_request_body on;
              proxy_set_header        Host            $host;
              proxy_set_header        X-Real-IP       $remote_addr;
              proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
          }
      
          location ~ ^/identity/?(.*) {
              proxy_pass http://172.16.10.254:5000/$1;
      
              proxy_pass_request_body on;
              proxy_set_header        Host            $host;
              proxy_set_header        X-Real-IP       $remote_addr;
              proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
          }
      }
      
    2. Verify the new configuration and restart NGINX:

      salt -C 'I@nginx:server' cmd.run 'nginx -t && nginx -s reload'
      
  6. Make the HTTP host resolvable from the browser through an internal DNS or a static configuration on hosts, for example, /etc/hosts in Linux.

    For a static configuration, run the following command in your console to add a record in /etc/hosts, where example.com is the vhost FQDN:

    echo "<grafana_public_ip_address> example.com" >> /etc/hosts
    
  7. Enable CORS requests in your browser or install a corresponding browser extension. For example, use the Chrome extension or Firefox extension.

Once done, proceed to Add the Gnocchi data source.