webdevops / azure-devops-exporter

Prometheus exporter for Azure DevOps (VSTS) including agent pools, builds, releases, deployments, pullrequests and repo stats
MIT License
144 stars 55 forks source link

builds with status other then "completed" #94

Open AlexMe99 opened 3 months ago

AlexMe99 commented 3 months ago

Hi together,

I really like your work for this exporter. It makes my life way easier currently! I'm using the exporter especially monitoring builds/pipeline runs in azure devops. After getting into the metrics and how they work, I get many information that I need.

Only one thing is currently missing for me and that is regarding running and non-completed builds. These are currently not scraped and after looking into the code, I saw that this is by design:

list, err := AzureDevopsClient.ListBuildHistoryWithStatus(project.Id, minTime, "completed")

[see here: https://github.com/webdevops/azure-devops-exporter/blob/main/metrics_build.go#L307C1-L307C93 ]

My question is, whether this is something, that HAS to be like this. Or whether it could be adjusted, so that not only completed, but also builds with other states can be scraped.

regards

Breee commented 2 months ago

One of our usecases for this exporter is to monitor running builds and see early if certain jobs have failed, so adding this would be great.

Probably with something like that?

list, err := AzureDevopsClient.ListBuildHistoryWithStatus(project.Id, minTime, "all")
[...]
     for _, timelineRecord := range timelineRecordList.List {
            if timelineRecord.Status != "completed" {
                continue
            }
[...]

Tracking if a Job is running might be more overhead and new logic to differ between running/finished buildjobs on a first glance when i'm looking at the code --> I would be fine if this expoter only fetches completed Build Jobs, as long as I can see them as soon as they are done

Breee commented 1 month ago

Added some changes in https://github.com/webdevops/azure-devops-exporter/pull/102 - for me that works fine