prometheus: counting the number of time series in a time range

Viewed 399

I'm trying to get deployment frequency in kubernetes. Counting replicasets doesn't work for us since we want to see the frequency of 'code deploys'. For this we can look at how many different images were deployed in a period of time. I'm trying to get this data from prometheus which has kubernetes metrics, we also have kube-state-metrics deployed.

I have tried things like -

count(
  group by (image) (
    (label_replace(kube_pod_owner{owner_kind="ReplicaSet", owner_name=~"app-.*"}, "replicaset", "$1", "owner_name", "(.*)")
      * on (replicaset) group_left kube_replicaset_spec_replicas{} 
    > 0)
    * on (pod) group_right kube_pod_container_info{container="app"}
  )
)
count(
  group by (image) (
    (count_over_time(kube_pod_container_info{container="app", pod=~"app.*"}[1d])
      * on(pod) group_left kube_pod_container_status_ready{}
    ) > 1
  )
)

Which aren't giving me quite what I want. I get a spike in the graph for the period where two images exist simultaneously, but that's what I'm looking for.

0 Answers
Related