@@ -19,6 +19,7 @@ type sonarrCollector struct {
1919 seriesMonitoredMetric * prometheus.Desc // Total number of monitored series
2020 seriesUnmonitoredMetric * prometheus.Desc // Total number of unmonitored series
2121 seriesFileSizeMetric * prometheus.Desc // Total fizesize of all series in bytes
22+ seriesTagsMetric * prometheus.Desc // Total number of series by tag
2223 seasonMetric * prometheus.Desc // Total number of seasons
2324 seasonDownloadedMetric * prometheus.Desc // Total number of downloaded seasons
2425 seasonMonitoredMetric * prometheus.Desc // Total number of monitored seasons
@@ -66,6 +67,12 @@ func NewSonarrCollector(conf *config.ArrConfig) *sonarrCollector {
6667 nil ,
6768 prometheus.Labels {"url" : conf .URL },
6869 ),
70+ seriesTagsMetric : prometheus .NewDesc (
71+ "sonarr_series_tag_total" ,
72+ "Total number of downloaded series by tag" ,
73+ []string {"tag" },
74+ prometheus.Labels {"url" : conf .URL },
75+ ),
6976 seasonMetric : prometheus .NewDesc (
7077 "sonarr_season_total" ,
7178 "Total number of seasons" ,
@@ -147,6 +154,7 @@ func (collector *sonarrCollector) Describe(ch chan<- *prometheus.Desc) {
147154 ch <- collector .seriesMonitoredMetric
148155 ch <- collector .seriesUnmonitoredMetric
149156 ch <- collector .seriesFileSizeMetric
157+ ch <- collector .seriesTagsMetric
150158 ch <- collector .seasonMetric
151159 ch <- collector .seasonDownloadedMetric
152160 ch <- collector .seasonMonitoredMetric
@@ -305,11 +313,25 @@ func (collector *sonarrCollector) Collect(ch chan<- prometheus.Metric) {
305313 return
306314 }
307315
316+ // Get tag details for series
317+ tagObjects := model.TagSeries {}
318+ if err := c .DoRequest ("tag/detail" , & tagObjects ); err != nil {
319+ log .Errorw ("Error getting tags" ,
320+ "error" , err )
321+ ch <- prometheus .NewInvalidMetric (collector .errorMetric , err )
322+ return
323+ }
324+
308325 ch <- prometheus .MustNewConstMetric (collector .seriesMetric , prometheus .GaugeValue , float64 (len (series )))
309326 ch <- prometheus .MustNewConstMetric (collector .seriesDownloadedMetric , prometheus .GaugeValue , float64 (seriesDownloaded ))
310327 ch <- prometheus .MustNewConstMetric (collector .seriesMonitoredMetric , prometheus .GaugeValue , float64 (seriesMonitored ))
311328 ch <- prometheus .MustNewConstMetric (collector .seriesUnmonitoredMetric , prometheus .GaugeValue , float64 (seriesUnmonitored ))
312329 ch <- prometheus .MustNewConstMetric (collector .seriesFileSizeMetric , prometheus .GaugeValue , float64 (seriesFileSize ))
330+ for _ , tag := range tagObjects {
331+ ch <- prometheus .MustNewConstMetric (collector .seriesTagsMetric , prometheus .GaugeValue , float64 (len (tag .SeriesIds )),
332+ tag .Label ,
333+ )
334+ }
313335 ch <- prometheus .MustNewConstMetric (collector .seasonMetric , prometheus .GaugeValue , float64 (seasons ))
314336 ch <- prometheus .MustNewConstMetric (collector .seasonDownloadedMetric , prometheus .GaugeValue , float64 (seasonsDownloaded ))
315337 ch <- prometheus .MustNewConstMetric (collector .seasonMonitoredMetric , prometheus .GaugeValue , float64 (seasonsMonitored ))
0 commit comments