Merge pull request #921 from aymericDD/fix/903

fix: iis metrics greater than IIS v7
This commit is contained in:
Ben Reedy
2022-01-31 18:53:59 +10:00
committed by GitHub

View File

@@ -1574,87 +1574,88 @@ func (c *IISCollector) collectW3SVC_W3WP(ctx *ScrapeContext, ch chan<- prometheu
pid, pid,
) )
if c.iis_version.major >= 8 { }
var W3SVC_W3WP_IIS8 []perflibW3SVC_W3WP_IIS8
if err := unmarshalObject(ctx.perfObjects["W3SVC_W3WP"], &W3SVC_W3WP_IIS8); err != nil { if c.iis_version.major >= 8 {
return nil, err var W3SVC_W3WP_IIS8 []perflibW3SVC_W3WP_IIS8
if err := unmarshalObject(ctx.perfObjects["W3SVC_W3WP"], &W3SVC_W3WP_IIS8); err != nil {
return nil, err
}
for _, app := range W3SVC_W3WP_IIS8 {
// Extract the apppool name from the format <PID>_<NAME>
pid := workerProcessNameExtractor.ReplaceAllString(app.Name, "$1")
name := workerProcessNameExtractor.ReplaceAllString(app.Name, "$2")
if name == "" {
log.Error("no instances found in W3SVC_W3WP_IIS8 - skipping collection")
break
}
if name == "_Total" ||
c.appBlacklistPattern.MatchString(name) ||
!c.appWhitelistPattern.MatchString(name) {
continue
} }
for _, app := range W3SVC_W3WP_IIS8 { ch <- prometheus.MustNewConstMetric(
// Extract the apppool name from the format <PID>_<NAME> c.RequestErrorsTotal,
pid := workerProcessNameExtractor.ReplaceAllString(app.Name, "$1") prometheus.CounterValue,
name := workerProcessNameExtractor.ReplaceAllString(app.Name, "$2") app.RequestErrors401,
if name == "" { name,
log.Error("no instances found in W3SVC_W3WP_IIS8 - skipping collection") pid,
break "401",
} )
if name == "_Total" || ch <- prometheus.MustNewConstMetric(
c.appBlacklistPattern.MatchString(name) || c.RequestErrorsTotal,
!c.appWhitelistPattern.MatchString(name) { prometheus.CounterValue,
continue app.RequestErrors403,
} name,
pid,
ch <- prometheus.MustNewConstMetric( "403",
c.RequestErrorsTotal, )
prometheus.CounterValue, ch <- prometheus.MustNewConstMetric(
app.RequestErrors401, c.RequestErrorsTotal,
name, prometheus.CounterValue,
pid, app.RequestErrors404,
"401", name,
) pid,
ch <- prometheus.MustNewConstMetric( "404",
c.RequestErrorsTotal, )
prometheus.CounterValue, ch <- prometheus.MustNewConstMetric(
app.RequestErrors403, c.RequestErrorsTotal,
name, prometheus.CounterValue,
pid, app.RequestErrors500,
"403", name,
) pid,
ch <- prometheus.MustNewConstMetric( "500",
c.RequestErrorsTotal, )
prometheus.CounterValue, ch <- prometheus.MustNewConstMetric(
app.RequestErrors404, c.WebSocketRequestsActive,
name, prometheus.CounterValue,
pid, app.WebSocketRequestsActive,
"404", name,
) pid,
ch <- prometheus.MustNewConstMetric( )
c.RequestErrorsTotal, ch <- prometheus.MustNewConstMetric(
prometheus.CounterValue, c.WebSocketConnectionAttempts,
app.RequestErrors500, prometheus.CounterValue,
name, app.WebSocketConnectionAttempts,
pid, name,
"500", pid,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WebSocketRequestsActive, c.WebSocketConnectionsAccepted,
prometheus.CounterValue, prometheus.CounterValue,
app.WebSocketRequestsActive, app.WebSocketConnectionsAccepted,
name, name,
pid, pid,
) )
ch <- prometheus.MustNewConstMetric( ch <- prometheus.MustNewConstMetric(
c.WebSocketConnectionAttempts, c.WebSocketConnectionsRejected,
prometheus.CounterValue, prometheus.CounterValue,
app.WebSocketConnectionAttempts, app.WebSocketConnectionsRejected,
name, name,
pid, pid,
) )
ch <- prometheus.MustNewConstMetric(
c.WebSocketConnectionsAccepted,
prometheus.CounterValue,
app.WebSocketConnectionsAccepted,
name,
pid,
)
ch <- prometheus.MustNewConstMetric(
c.WebSocketConnectionsRejected,
prometheus.CounterValue,
app.WebSocketConnectionsRejected,
name,
pid,
)
}
} }
} }