Skip to content

Commit

Permalink
fix: missing label
Browse files Browse the repository at this point in the history
  • Loading branch information
martabal committed Oct 27, 2024
1 parent 9f38536 commit ec7f09d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func Torrent(result *API.Info, r *prometheus.Registry) {
if app.Exporter.ExperimentalFeature.EnableLabelWithHash {
labels = append(labels, TorrentLabelHash)
}
labelsWithTag := append(labels, "tag")

metrics := map[string]*prometheus.GaugeVec{
"qbittorrent_torrent_eta": newGaugeVec("qbittorrent_torrent_eta", "The current ETA for each torrent (in seconds)", labels),
Expand All @@ -56,7 +57,7 @@ func Torrent(result *API.Info, r *prometheus.Registry) {
"qbittorrent_torrent_session_uploaded_bytes": newGaugeVec("qbittorrent_torrent_session_uploaded_bytes", "The current session upload amount of torrents (in bytes)", labels),
"qbittorrent_torrent_total_downloaded_bytes": newGaugeVec("qbittorrent_torrent_total_downloaded_bytes", "The current total download amount of torrents (in bytes)", labels),
"qbittorrent_torrent_total_uploaded_bytes": newGaugeVec("qbittorrent_torrent_total_uploaded_bytes", "The current total upload amount of torrents (in bytes)", labels),
"qbittorrent_torrent_tags": newGaugeVec("qbittorrent_tags", "All tags associated to this torrent", append(labels, "tag")),
"qbittorrent_torrent_tags": newGaugeVec("qbittorrent_tags", "All tags associated to this torrent", labelsWithTag),
"qbittorrent_torrent_states": newGaugeVec("qbittorrent_torrent_states", "The current state of torrents", []string{TorrentLabelName}),
}

Expand Down Expand Up @@ -129,10 +130,9 @@ func Torrent(result *API.Info, r *prometheus.Registry) {
if torrent.Tags != "" {
tags := strings.Split(torrent.Tags, ", ")
for _, tag := range tags {
tagLabels := prometheus.Labels{
TorrentLabelName: torrent.Name,
TorrentLabelHash: torrent.Hash,
"tag": tag,
tagLabels := prometheus.Labels{TorrentLabelName: torrent.Name, "tag": tag}
if app.Exporter.ExperimentalFeature.EnableLabelWithHash {
tagLabels[TorrentLabelHash] = torrent.Hash
}
metrics["qbittorrent_torrent_tags"].With(tagLabels).Set(1)
}
Expand Down

0 comments on commit ec7f09d

Please sign in to comment.