Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Added support for dupliacted backends in upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
zakharovvi committed Feb 14, 2017
1 parent f39792f commit 8906abc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nginx_vts_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"strconv"
"time"

"github.com/prometheus/client_golang/prometheus"
Expand Down Expand Up @@ -252,7 +253,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
// UpstreamZones
for name, upstreamList := range nginxVtx.UpstreamZones {
var total, one, two, three, four, five, inbytes, outbytes float64
for _, s := range upstreamList {
for i, s := range upstreamList {
total += float64(s.RequestCounter)
one += float64(s.Responses.OneXx)
two += float64(s.Responses.TwoXx)
Expand All @@ -263,7 +264,8 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
inbytes += float64(s.InBytes)
outbytes += float64(s.OutBytes)

ch <- prometheus.MustNewConstMetric(e.upstreamMetrics["response"], prometheus.GaugeValue, float64(s.ResponseMsec), name, s.Server)
backend := fmt.Sprintf("%s-%s", s.Server, strconv.Itoa(i))
ch <- prometheus.MustNewConstMetric(e.upstreamMetrics["response"], prometheus.GaugeValue, float64(s.ResponseMsec), name, backend)
}

ch <- prometheus.MustNewConstMetric(e.upstreamMetrics["requests"], prometheus.CounterValue, total, name, "total")
Expand Down

0 comments on commit 8906abc

Please sign in to comment.