From 7de1262f8746af2fed9ec962c551dede2f7db585 Mon Sep 17 00:00:00 2001 From: phillip-toohill Date: Tue, 27 Feb 2024 09:47:05 -0600 Subject: [PATCH] Monitoring: adding openstack metrics exporter --- ...prometheus-openstack-metrics-exporter.yaml | 43 +++++++++ .gitmodules | 3 + docs/openstack-metrics-exporter.md | 24 +++++ .../openstack-metrics-exporter/clouds-yaml | 11 +++ ...stack-metrics-exporter-helm-overrides.yaml | 89 +++++++++++++++++++ submodules/openstack-exporter | 1 + 6 files changed, 171 insertions(+) create mode 100644 .github/workflows/helm-prometheus-openstack-metrics-exporter.yaml create mode 100644 docs/openstack-metrics-exporter.md create mode 100644 helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml create mode 100644 helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml create mode 160000 submodules/openstack-exporter diff --git a/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml b/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml new file mode 100644 index 00000000..29ff3001 --- /dev/null +++ b/.github/workflows/helm-prometheus-openstack-metrics-exporter.yaml @@ -0,0 +1,43 @@ +name: Helm GitHub Actions for openstack-metrics-exporter + +on: + pull_request: + paths: + - helm-configs/monitoring/openstack-metrics-exporter/** + - kustomize/monitoring/openstack-metrics-exporter/** + - .github/workflows/helm-openstack-metrics-exporter.yaml +jobs: + helm: + name: Helm + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: azure/setup-helm@v3 + with: + version: latest + token: "${{ secrets.GITHUB_TOKEN }}" + id: helm + - name: Kubectl Install + working-directory: /usr/local/bin/ + run: | + if [ ! -f /usr/local/bin/kubectl ]; then + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + chmod +x ./kubectl + fi + - name: Pull Openstack Exporter submodules + run: | + git submodule update --init submodules/openstack-exporter + - name: Run Helm Template + run: | + cd submodules/openstack-exporter/charts/ + ${{ steps.helm.outputs.helm-path }} template os-metrics ./prometheus-openstack-exporter \ + --namespace=openstack \ + --wait \ + --timeout 120m \ + -f ${{ github.workspace }}/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml > /tmp/rendered.yaml + - name: Return helm Build + uses: actions/upload-artifact@v2 + with: + name: helm-openstack-exporter-artifact-${{ matrix.overlays }} + path: /tmp/rendered.yaml diff --git a/.gitmodules b/.gitmodules index 92b0db6b..8fd61a81 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "submodules/mariadb-operator"] path = submodules/mariadb-operator url = https://github.com/mariadb-operator/mariadb-operator +[submodule "submodules/openstack-exporter"] + path = submodules/openstack-exporter + url = https://github.com/openstack-exporter/helm-charts diff --git a/docs/openstack-metrics-exporter.md b/docs/openstack-metrics-exporter.md new file mode 100644 index 00000000..fed12da8 --- /dev/null +++ b/docs/openstack-metrics-exporter.md @@ -0,0 +1,24 @@ +## Openstack MetricsExporter + +We are using Prometheus for monitoring and metrics collection backend along with the openstack exporter to gather openstack resource metrics +For more information see: https://prometheus.io and https://github.com/openstack-exporter/openstack-exporter + +## Deploy the Prometheus Openstack Exporter + +### Create clouds-yaml secret +Modify genestack/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml with the appropriate settings and create the secret. + +```shell +kubectl create secret generic clouds-yaml-secret --from-file /opt/genestack/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml +``` + +### Install openstack-metrics-exporter helm chart +```shell +cd /opt/genestack/submodules/openstack-exporter/helm-charts/charts + +helm upgrade --install os-metrics ./prometheus-openstack-exporter \ + --namespace=openstack \ + --timeout 15m \ + -f /opt/genestack/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml \ + --set clouds_yaml_config="$(kubectl get secret clouds-yaml-secret -o jsonpath='{.data.clouds-yaml}' | base64 -d)" +``` diff --git a/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml b/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml new file mode 100644 index 00000000..6f70ee7c --- /dev/null +++ b/helm-configs/monitoring/openstack-metrics-exporter/clouds-yaml @@ -0,0 +1,11 @@ +clouds.yaml: | + clouds: + default: + region_name: RegionOne + auth: + username: admin + password: + project_name: admin + project_domain_name: default + user_domain_name: default + auth_url: 'http://keystone-api.openstack.svc.cluster.local:5000/v3' diff --git a/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml b/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml new file mode 100644 index 00000000..0854e377 --- /dev/null +++ b/helm-configs/monitoring/openstack-metrics-exporter/openstack-metrics-exporter-helm-overrides.yaml @@ -0,0 +1,89 @@ +--- +# Choose endpoint type (this will override the value of clouds.yaml) +endpoint_type: public +# Ignored when multicloud.enabled: true +cloud: default + +replicaCount: 1 + +image: + repository: ghcr.io/openstack-exporter/openstack-exporter + tag: 1.7.0 + pullPolicy: Always + +serviceMonitor: + interval: 3m + scrapeTimeout: 30s + +multicloud: + # Enable multicloud (i.e. /probe?... targets) + # Doc: https://github.com/openstack-exporter/openstack-exporter#description + enabled: false + # Monitor the exporter's internal metrics (i.e. /metrics) + selfmonitor: false + # List of clouds to scrape, and the services to scrape from them + clouds: + - name: default + services: + - volume + - image + - identity + - compute + - network + - placement + - load-balancer + - object-store + #- container-infra + #- dns + #- baremetal + - gnocchi + #- database + - orchestration + + # - name: cloud1 + # services: + # - volume + # - name: cloud2 + # services: + # - volume + # - image + # - identity + # - compute + # - network + # - placement # NB this needs the openstack-exporter release > 1.4.0 + +# Add extra args to the exporter. +# Doc: https://github.com/openstack-exporter/openstack-exporter#command-line-options +#extraArgs: +# - --disable-service.baremetal +# - --disable-service.container-infra +# - --disable-service.object-store + +# Add extra environment variables +# extraEnvs: +# "ENV_VAR": "value" + +# Add extra labels +#commonLabels: +# prometheus.io/scrape: "true" +# prometheus.io/monitor: "true" + +# Generate a secret for clouds.yaml +# Doc: https://github.com/openstack-exporter/openstack-exporter#openstack-configuration +clouds_yaml_config: | + clouds.yaml: | + clouds: + default: + region_name: RegionOne + auth: + username: admin + password: + project_name: admin + project_domain_name: default + user_domain_name: default + auth_url: 'http://keystone-api.openstack.svc.cluster.local:5000/v3' +# In case of multicloud.enabled +# cloud1: +# ... +# cloud2: +# ... diff --git a/submodules/openstack-exporter b/submodules/openstack-exporter new file mode 160000 index 00000000..fe694218 --- /dev/null +++ b/submodules/openstack-exporter @@ -0,0 +1 @@ +Subproject commit fe6942189cbc5d836716235ff20e89f9d1dd5ed4