1

I want to get the number of pipelines that passed that are happening within my gitlab repo. I am trying to get the total number of data points within a 4w(1 month). I am using grafana to see the data visually. I first start getting the points individually and start counting them manually and checking them them in our repo pipeline to make sure they match which they do.

query=pipeline_status{branch="master", status="success", source!="schedule", passed_with_warnings="no",project_repo="nik"}

Note: These query gives the 22 data points they were run and how long they ran for

Grafana Points

EDIT:

I wanted to count the number of pipeline status within that day, so I queried for with a step of 1d

count(pipeline_duration{branch="master", status="success", source!="schedule", passed_with_warnings="no",project_id="930"}[1d])OR vector(0)

This shows the correct 22 data points within that month period (3/20 - 4/20) day qyery

Now when I add a count to my query for a 4 week step doesn't match. I should expect to see 22 data points, but graph seems off.

query=count(pipeline_status{branch="master", status="success", source!="schedule", passed_with_warnings="no",project_repo="nik"}[4w])OR vector(0)'

query

  • Also, it would be easier to help, if you'll add a couple examples of time series returned by your first query. – markalex Apr 21 '23 at 17:28
  • Can you see the above images @markalex – Max Bojorquez Apr 21 '23 at 18:36
  • Well, it could be the rare case when screenshots were helpful) – markalex Apr 21 '23 at 18:49
  • I'm not familiar with victoriaMetrics, but it seems suspicious that your last seen value is for `13.04`, while clearly there are more values later. If you are interested in reasons, I would advise you to check results of this query in web UI of your server (assuming it is similar to UI of Prometheus) and documentation of metricsQL on `count` applied to range vectors. – markalex Apr 21 '23 at 18:55

2 Answers2

0

Try running count_over_time function in the following fashion:

count_over_time(pipeline_status{branch="master", status="success", source!="schedule", passed_with_warnings="no",project_repo="nik"}[4w])

count_over_time(series_selector[d]) is a rollup function, which calculates the number of raw samples on the given lookbehind window d per each time series returned from the given series_selector.

Metric names are stripped from the resulting rollups. Add keep_metric_names modifier in order to keep metric names.

hagen1778
  • 669
  • 3
  • 8
  • It didn't seem to work. Adding the `count_over_time` gave me a data that was zero – Max Bojorquez Apr 21 '23 at 18:41
  • This is unexpected. Are you sure the label filters were correct? Did you use any extra filtering? Can you share the raw datapoints exported via export API (https://docs.victoriametrics.com/#how-to-export-data-in-json-line-format)? – hagen1778 Apr 22 '23 at 21:01
0

I'm not familiar with VictoriaMetrics, so proceed with caution.

If its metricQL is reverse compatible with promQL, you can use combination of last_over_time and count to calculate number of separate in time values.

For your metric it would be

count(last_over_time(pipeline_status{branch="master", status="success", source!="schedule", passed_with_warnings="no",project_repo="nik"} [4w]))

Here last_over_time "stretches" last seen value till now, if it was seen within specified time range.

markalex
  • 8,623
  • 2
  • 7
  • 32