Enable metrics on harbor tile in Tanzu Platform
search cancel

Enable metrics on harbor tile in Tanzu Platform

book

Article ID: 404343

calendar_today

Updated On:

Products

VMware Tanzu Kubernetes Grid Integrated Edition

Issue/Introduction

One want to expose Harbor metrics, needed for operators and administrators to monitor how your Harbor instance is running in real time

Environment

Operation manager v3.x

Harbor tile v2.x

VMware Tanzu Kubernetes Grid Integrated Edition v1.x

Resolution

Follow below steps to enable/expose metrics on harbor:-

  • Firstly we have upload os-conf release to make changes in harbor tile VM. 

    a) If Internet is enabled on jumpbox where we can run bosh command then you can run below command directly to upload release:-

    bosh upload-release https://bosh.io/d/github.com/cloudfoundry/os-conf-release?v=22.2.1 --sha1 daf34e35f1ac678ba05db3496c4226064b99b3e4

    b) If no internet then you have to download the release from https://bosh.io/releases/github.com/cloudfoundry/os-conf-release?all=1  and upload the tar file. 

    https://bosh.io/docs/uploading-releases/#:~:text=Alternatively%2C%20if%20you%20have%20a%20release%20tarball%20on%20your%20local%20machine%3A

    bosh  upload-release <PATH_OF_THE_TAR_FILE>
  • Then create runtime-config file with name "runtime.yml" . Update the harbor deployment name under "deployments" in below config file.

    releases:  
      - name: "os-conf"   
         version: "22.1.3" 
    addons:  
      - name: os-configuration   
         jobs:      
         - name: pre-start-script        
            release: os-conf        
            properties:          
            script: |-             
              #!/bin/bash             
              harbor_config="/var/vcap/jobs/harbor/config/harbor.yml"     
              static_port=9090       
              if [ -f "${harbor_config}" ]; then  
                  if [ grep -q $static_port  $harbor_config ] ; then
                      echo "metric parameter is already present"
                  else 
                    echo -e "\nmetric:\n   "enabled: true"\n   "port: 9090"\n   "path: /metrics"" >> ${harbor_config}  
                  fi
              fi              
    include:     
        deployments: harbor-container-registry-XXXXXXXXX  # you can define which deployments would be applied this runtime config. 
  • Update the runtime config.

    bosh update-runtime-config runtime.yml
  • Then just simply do the "Apply change" on harbor tile from opsmanager UI.
  • It will deploy one smoke test VM and will enable the metrics api on harbor server. You can verify by checking the "/var/vcap/jobs/harbor/config/harbor.yml". Below section would be added in it.
    metric:   
      enabled: true   
      port: 9090   
      path: /metrics
  • At the end you can fetch all metrics from harbor server on port 9090.
    curl -v -k  http://<HARBOR_IP>:9090/metrics