keptn / lifecycle-toolkit

Toolkit for cloud-native application lifecycle management
https://keptn.sh
Apache License 2.0
272 stars 111 forks source link

kubectl get KeptnMetrics not showing interval #2744

Closed agardnerIT closed 6 months ago

agardnerIT commented 6 months ago

Keptn version: v0.9.0

Retrieving all KeptnMetrics does not show INTERVAL:

kubectl -n default get keptnmetrics
NAME                             PROVIDER           QUERY                                                                                                                                                                                 INTERVAL   VALUE
prometheus-http-requests-total   local-prometheus   prometheus_http_requests_total{code="200"}              768
Vickysomtee commented 6 months ago

@agardnerIT what would be the proper way to fix this?

agardnerIT commented 6 months ago

Looking here it seems that the v1alpha3 spec looks at .spec.range.interval but output from my cluster shows:

apiVersion: metrics.keptn.sh/v1alpha3
kind: KeptnMetric
metadata:
  annotations:
      ...
  name: prometheus-http-requests-total
  namespace: default
spec:
  fetchIntervalSeconds: 10
  provider:
    name: local-prometheus
  query: prometheus_http_requests_total{code="200", handler="/-/healthy", job="kube-prom-stack-kube-prome-prometheus",
    namespace="default",
    service="kube-prom-stack-kube-prome-prometheus"}
status:
  errMsg: no values in query result
  lastUpdated: "2024-01-03T01:25:14Z"
  rawValue: IjU1Ig==
  value: "55"

Which suggests that it should actually be .spec.fetchIntervalSeconds

However, I'll defer to @odubajDT on this so please wait for him to respond before working on this.

RealAnna commented 6 months ago

Hi @agardnerIT @Vickysomtee the only thing to do is to change the path in each api occurence for future generation ex. valpha3 is here and update it at the jsonPath in our charts like where you linked. I will add this to the goodfirst issues 🚀

Vickysomtee commented 6 months ago

Hi @agardnerIT @Vickysomtee the only thing to do is to change the path in each api occurence for future generation ex. valpha3 is here and update it at the jsonPath in our charts like where you linked. I will add this to the goodfirst issues 🚀

@RealAnna to be sure I understood you correctly, you mean we are to change .spec.range.interval to .spec.fetchIntervalSeconds? Also, should this change take place anywhere .spec.range.interval appears across the codebase?

rakshitgondwal commented 6 months ago

The interval field for kuebctl get keptnmetric was introduced to have the value of spec.range.interval, see #1677 for more info. I think there is no actual bug in this case as Adam hasn't specified any interval field inside his metric so the interval field should come out as empty.

RealAnna commented 6 months ago

@rakshitgondwal is 100% right, this is just a naming misunderstanding. Closing this