Bug 2218468

Summary: [CDI] Metrics names failed promlint linter
Product: Container Native Virtualization (CNV) Reporter: Aviv Litman <alitman>
Component: MetricsAssignee: Aviv Litman <alitman>
Status: CLOSED ERRATA QA Contact: Ahmad <ahafe>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.13.0CC: aadmi, dbasunag, kmajcher, sradco, stirabos
Target Milestone: ---   
Target Release: 4.14.0   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: v4.14.0.rhel9-1708 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-08 14:05:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Aviv Litman 2023-06-29 09:14:45 UTC
Description of problem:
We created a metric name linter in kubevirt/containerized-data-importer based on promlint: https://github.com/kubevirt/containerized-data-importer/pull/2774.

This metrics names failed:
clone_progress: counter metrics should have "_total" or "_timestamp_seconds" suffix
clone_progress: name need to start with 'kubevirt_'
kubevirt_cdi_incomplete_storageprofiles_total: non-counter metrics should not have "_total" suffix
kubevirt_cdi_operator_up_total: non-counter metrics should not have "_total" suffix

In order to pass the linter the names can be:
`kubevirt_cdi_incomplete_storageprofiles_total` to `kubevirt_cdi_incomplete_storageprofiles`
`kubevirt_cdi_operator_up_total` to `kubevirt_cdi_operator_up`

***clone_progress will be fixed in: https://github.com/kubevirt/containerized-data-importer/issues/2515 and not in this bug, since also functionally change is needed.


Version-Release number of selected component (if applicable):
4.13

How reproducible:
100%

Steps to Reproduce:
1. cd containerized-data-importer
2. checkout the pr https://github.com/kubevirt/containerized-data-importer/pull/2774 
3. remove the ignored metrics from excludedMetrics list in  
tools/prom-metrics-collector/metrics_collector.go (in order to see the erros)
4.make lint-metrics or make test-lint


Actual results:
some metric names are not aligned with promlint linter.

Expected results:
Metrics named will be aligned with promlint linter and Prometheus best practices.

Additional info:
as for now the list of metrics are ignored in the linter.

Comment 1 Assaf Admi 2023-07-13 07:10:08 UTC
In addition, in https://github.com/kubevirt/hostpath-provisioner-operator, kubevirt_hpp_operator_up_total metric is failing the metrics linter.

Comment 2 Aviv Litman 2023-08-01 08:34:58 UTC
(In reply to Assaf Admi from comment #1)
> In addition, in https://github.com/kubevirt/hostpath-provisioner-operator,
> kubevirt_hpp_operator_up_total metric is failing the metrics linter.

HPP will be handled in a separate bug: https://bugzilla.redhat.com/show_bug.cgi?id=2224828

Comment 3 Aviv Litman 2023-08-08 11:48:45 UTC
clone_ will be fixed in: https://github.com/kubevirt/containerized-data-importer/issues/2515

Comment 4 Aviv Litman 2023-08-08 11:49:22 UTC
(In reply to Aviv Litman from comment #3)
> clone_ will be fixed in:
> https://github.com/kubevirt/containerized-data-importer/issues/2515

*clone_progress

Comment 5 Ahmad 2023-09-26 17:30:45 UTC
QA: Verfird 
Deployed: OCP-4.14.0-rc.2
Deployed: CNV-v4.14.0.rhel9-2086


`kubevirt_cdi_incomplete_storageprofiles_total` renamed to `kubevirt_cdi_incomplete_storageprofiles`
`kubevirt_cdi_operator_up_total` renamed to `kubevirt_cdi_operator_up`



[cloud-user@ocp-psi-executor ahmad]$ oc exec -n openshift-monitoring prometheus-k8s-0 -c prometheus -- curl -s http://127.0.0.1:9090/api/v1/query?query=kubevirt_cdi_incomplete_storageprofiles | jq .
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "__name__": "kubevirt_cdi_incomplete_storageprofiles",
          "container": "cdi-controller",
          "endpoint": "metrics",
          "instance": "10.128.2.69:8080",
          "job": "cdi-prometheus-metrics",
          "namespace": "openshift-cnv",
          "pod": "cdi-deployment-5475f5cf9-pfct6",
          "service": "cdi-prometheus-metrics"
        },
        "value": [
          1695749372.120,
          "0"
        ]
      }
    ]
  }
}
[cloud-user@ocp-psi-executor ahmad]$ oc exec -n openshift-monitoring prometheus-k8s-0 -c prometheus -- curl -s http://127.0.0.1:9090/api/v1/query?query=kubevirt_cdi_operator_up | jq .
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "__name__": "kubevirt_cdi_operator_up"
        },
        "value": [
          1695749387.890,
          "1"
        ]
      }
    ]
  }
}
[cloud-user@ocp-psi-executor ahmad]$

Comment 7 errata-xmlrpc 2023-11-08 14:05:53 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Important: OpenShift Virtualization 4.14.0 Images security and bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2023:6817