mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-02 16:46:35 +00:00
adfs: Implement PDH collector (#1656)
This commit is contained in:
@@ -29,6 +29,7 @@ run:
|
|||||||
linters-settings:
|
linters-settings:
|
||||||
gosec:
|
gosec:
|
||||||
excludes:
|
excludes:
|
||||||
|
- G101 # Potential hardcoded credentials
|
||||||
- G115 # integer overflow conversion
|
- G115 # integer overflow conversion
|
||||||
|
|
||||||
gci:
|
gci:
|
||||||
|
|||||||
@@ -77,19 +77,19 @@ func (c *Collector) Close(_ *slog.Logger) error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||||
if utils.PDHEnabled() {
|
if utils.PDHEnabled() {
|
||||||
counters := []string{
|
counters := []string{
|
||||||
RequestsPerSecond,
|
requestsPerSecond,
|
||||||
RequestProcessingTime,
|
requestProcessingTime,
|
||||||
RetrievalsPerSecond,
|
retrievalsPerSecond,
|
||||||
RetrievalProcessingTime,
|
retrievalProcessingTime,
|
||||||
FailedRequestsPerSecond,
|
failedRequestsPerSecond,
|
||||||
IssuedRequestsPerSecond,
|
issuedRequestsPerSecond,
|
||||||
PendingRequestsPerSecond,
|
pendingRequestsPerSecond,
|
||||||
RequestCryptographicSigningTime,
|
requestCryptographicSigningTime,
|
||||||
RequestPolicyModuleProcessingTime,
|
requestPolicyModuleProcessingTime,
|
||||||
ChallengeResponsesPerSecond,
|
challengeResponsesPerSecond,
|
||||||
ChallengeResponseProcessingTime,
|
challengeResponseProcessingTime,
|
||||||
SignedCertificateTimestampListsPerSecond,
|
signedCertificateTimestampListsPerSecond,
|
||||||
SignedCertificateTimestampListProcessingTime,
|
signedCertificateTimestampListProcessingTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -317,79 +317,79 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestsPerSecond,
|
c.requestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[RequestsPerSecond].FirstValue,
|
adcsData[requestsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestProcessingTime,
|
c.requestProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[RequestProcessingTime].FirstValue),
|
utils.MilliSecToSec(adcsData[requestProcessingTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalsPerSecond,
|
c.retrievalsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[RetrievalsPerSecond].FirstValue,
|
adcsData[retrievalsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.retrievalProcessingTime,
|
c.retrievalProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[RetrievalProcessingTime].FirstValue),
|
utils.MilliSecToSec(adcsData[retrievalProcessingTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.failedRequestsPerSecond,
|
c.failedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[FailedRequestsPerSecond].FirstValue,
|
adcsData[failedRequestsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.issuedRequestsPerSecond,
|
c.issuedRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[IssuedRequestsPerSecond].FirstValue,
|
adcsData[issuedRequestsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.pendingRequestsPerSecond,
|
c.pendingRequestsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[PendingRequestsPerSecond].FirstValue,
|
adcsData[pendingRequestsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestCryptographicSigningTime,
|
c.requestCryptographicSigningTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[RequestCryptographicSigningTime].FirstValue),
|
utils.MilliSecToSec(adcsData[requestCryptographicSigningTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.requestPolicyModuleProcessingTime,
|
c.requestPolicyModuleProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[RequestPolicyModuleProcessingTime].FirstValue),
|
utils.MilliSecToSec(adcsData[requestPolicyModuleProcessingTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponsesPerSecond,
|
c.challengeResponsesPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[ChallengeResponsesPerSecond].FirstValue,
|
adcsData[challengeResponsesPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.challengeResponseProcessingTime,
|
c.challengeResponseProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[ChallengeResponseProcessingTime].FirstValue),
|
utils.MilliSecToSec(adcsData[challengeResponseProcessingTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListsPerSecond,
|
c.signedCertificateTimestampListsPerSecond,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adcsData[SignedCertificateTimestampListsPerSecond].FirstValue,
|
adcsData[signedCertificateTimestampListsPerSecond].FirstValue,
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.signedCertificateTimestampListProcessingTime,
|
c.signedCertificateTimestampListProcessingTime,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
utils.MilliSecToSec(adcsData[SignedCertificateTimestampListProcessingTime].FirstValue),
|
utils.MilliSecToSec(adcsData[signedCertificateTimestampListProcessingTime].FirstValue),
|
||||||
name,
|
name,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
package adcs
|
package adcs
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RequestsPerSecond = "Requests/sec"
|
challengeResponseProcessingTime = "Challenge Response processing time (ms)"
|
||||||
RequestProcessingTime = "Request processing time (ms)"
|
challengeResponsesPerSecond = "Challenge Responses/sec"
|
||||||
RetrievalsPerSecond = "Retrievals/sec"
|
failedRequestsPerSecond = "Failed Requests/sec"
|
||||||
RetrievalProcessingTime = "Retrieval processing time (ms)"
|
issuedRequestsPerSecond = "Issued Requests/sec"
|
||||||
FailedRequestsPerSecond = "Failed Requests/sec"
|
pendingRequestsPerSecond = "Pending Requests/sec"
|
||||||
IssuedRequestsPerSecond = "Issued Requests/sec"
|
requestCryptographicSigningTime = "Request cryptographic signing time (ms)"
|
||||||
PendingRequestsPerSecond = "Pending Requests/sec"
|
requestPolicyModuleProcessingTime = "Request policy module processing time (ms)"
|
||||||
RequestCryptographicSigningTime = "Request cryptographic signing time (ms)"
|
requestProcessingTime = "Request processing time (ms)"
|
||||||
RequestPolicyModuleProcessingTime = "Request policy module processing time (ms)"
|
requestsPerSecond = "Requests/sec"
|
||||||
ChallengeResponsesPerSecond = "Challenge Responses/sec"
|
retrievalProcessingTime = "Retrieval processing time (ms)"
|
||||||
ChallengeResponseProcessingTime = "Challenge Response processing time (ms)"
|
retrievalsPerSecond = "Retrievals/sec"
|
||||||
SignedCertificateTimestampListsPerSecond = "Signed Certificate Timestamp Lists/sec"
|
signedCertificateTimestampListProcessingTime = "Signed Certificate Timestamp List processing time (ms)"
|
||||||
SignedCertificateTimestampListProcessingTime = "Signed Certificate Timestamp List processing time (ms)"
|
signedCertificateTimestampListsPerSecond = "Signed Certificate Timestamp Lists/sec"
|
||||||
)
|
)
|
||||||
|
|
||||||
type perflibADCS struct {
|
type perflibADCS struct {
|
||||||
|
|||||||
@@ -3,12 +3,16 @@
|
|||||||
package adfs
|
package adfs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"math"
|
"math"
|
||||||
|
|
||||||
"github.com/alecthomas/kingpin/v2"
|
"github.com/alecthomas/kingpin/v2"
|
||||||
|
"github.com/prometheus-community/windows_exporter/pkg/perfdata"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
"github.com/prometheus-community/windows_exporter/pkg/perflib"
|
||||||
"github.com/prometheus-community/windows_exporter/pkg/types"
|
"github.com/prometheus-community/windows_exporter/pkg/types"
|
||||||
|
"github.com/prometheus-community/windows_exporter/pkg/utils"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/yusufpapurcu/wmi"
|
"github.com/yusufpapurcu/wmi"
|
||||||
)
|
)
|
||||||
@@ -22,6 +26,8 @@ var ConfigDefaults = Config{}
|
|||||||
type Collector struct {
|
type Collector struct {
|
||||||
config Config
|
config Config
|
||||||
|
|
||||||
|
perfDataCollector *perfdata.Collector
|
||||||
|
|
||||||
adLoginConnectionFailures *prometheus.Desc
|
adLoginConnectionFailures *prometheus.Desc
|
||||||
artifactDBFailures *prometheus.Desc
|
artifactDBFailures *prometheus.Desc
|
||||||
avgArtifactDBQueryTime *prometheus.Desc
|
avgArtifactDBQueryTime *prometheus.Desc
|
||||||
@@ -63,8 +69,8 @@ type Collector struct {
|
|||||||
upAuthenticationFailures *prometheus.Desc
|
upAuthenticationFailures *prometheus.Desc
|
||||||
upAuthentications *prometheus.Desc
|
upAuthentications *prometheus.Desc
|
||||||
windowsIntegratedAuthentications *prometheus.Desc
|
windowsIntegratedAuthentications *prometheus.Desc
|
||||||
wsfedTokenRequests *prometheus.Desc
|
wsFedTokenRequests *prometheus.Desc
|
||||||
wstrustTokenRequests *prometheus.Desc
|
wsTrustTokenRequests *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(config *Config) *Collector {
|
func New(config *Config) *Collector {
|
||||||
@@ -88,6 +94,10 @@ func (c *Collector) GetName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
func (c *Collector) GetPerfCounter(_ *slog.Logger) ([]string, error) {
|
||||||
|
if utils.PDHEnabled() {
|
||||||
|
return []string{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
return []string{"AD FS"}, nil
|
return []string{"AD FS"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,6 +106,61 @@ func (c *Collector) Close(_ *slog.Logger) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||||
|
if utils.PDHEnabled() {
|
||||||
|
counters := []string{
|
||||||
|
adLoginConnectionFailures,
|
||||||
|
certificateAuthentications,
|
||||||
|
deviceAuthentications,
|
||||||
|
extranetAccountLockouts,
|
||||||
|
federatedAuthentications,
|
||||||
|
passportAuthentications,
|
||||||
|
passiveRequests,
|
||||||
|
passwordChangeFailed,
|
||||||
|
passwordChangeSucceeded,
|
||||||
|
tokenRequests,
|
||||||
|
windowsIntegratedAuthentications,
|
||||||
|
oAuthAuthZRequests,
|
||||||
|
oAuthClientAuthentications,
|
||||||
|
oAuthClientAuthenticationFailures,
|
||||||
|
oAuthClientCredentialRequestFailures,
|
||||||
|
oAuthClientCredentialRequests,
|
||||||
|
oAuthClientPrivateKeyJWTAuthenticationFailures,
|
||||||
|
oAuthClientPrivateKeyJWTAuthentications,
|
||||||
|
oAuthClientBasicAuthenticationFailures,
|
||||||
|
oAuthClientBasicAuthentications,
|
||||||
|
oAuthClientSecretPostAuthenticationFailures,
|
||||||
|
oAuthClientSecretPostAuthentications,
|
||||||
|
oAuthClientWindowsAuthenticationFailures,
|
||||||
|
oAuthClientWindowsAuthentications,
|
||||||
|
oAuthLogonCertRequestFailures,
|
||||||
|
oAuthLogonCertTokenRequests,
|
||||||
|
oAuthPasswordGrantRequestFailures,
|
||||||
|
oAuthPasswordGrantRequests,
|
||||||
|
oAuthTokenRequests,
|
||||||
|
samlPTokenRequests,
|
||||||
|
ssoAuthenticationFailures,
|
||||||
|
ssoAuthentications,
|
||||||
|
wsFedTokenRequests,
|
||||||
|
wsTrustTokenRequests,
|
||||||
|
usernamePasswordAuthenticationFailures,
|
||||||
|
usernamePasswordAuthentications,
|
||||||
|
externalAuthentications,
|
||||||
|
externalAuthNFailures,
|
||||||
|
artifactDBFailures,
|
||||||
|
avgArtifactDBQueryTime,
|
||||||
|
configDBFailures,
|
||||||
|
avgConfigDBQueryTime,
|
||||||
|
federationMetadataRequests,
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
|
||||||
|
c.perfDataCollector, err = perfdata.NewCollector("AD FS", []string{"*"}, counters)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to create AD FS collector: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.adLoginConnectionFailures = prometheus.NewDesc(
|
c.adLoginConnectionFailures = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "ad_login_connection_failures_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "ad_login_connection_failures_total"),
|
||||||
"Total number of connection failures to an Active Directory domain controller",
|
"Total number of connection failures to an Active Directory domain controller",
|
||||||
@@ -288,13 +353,13 @@ func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
|||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.wsfedTokenRequests = prometheus.NewDesc(
|
c.wsFedTokenRequests = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "wsfed_token_requests_success_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "wsfed_token_requests_success_total"),
|
||||||
"Total number of successful RP tokens issued over WS-Fed protocol",
|
"Total number of successful RP tokens issued over WS-Fed protocol",
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
c.wstrustTokenRequests = prometheus.NewDesc(
|
c.wsTrustTokenRequests = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "wstrust_token_requests_success_total"),
|
prometheus.BuildFQName(types.Namespace, Name, "wstrust_token_requests_success_total"),
|
||||||
"Total number of successful RP tokens issued over WS-Trust protocol",
|
"Total number of successful RP tokens issued over WS-Trust protocol",
|
||||||
nil,
|
nil,
|
||||||
@@ -358,55 +423,17 @@ func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type perflibADFS struct {
|
|
||||||
AdLoginConnectionFailures float64 `perflib:"AD Login Connection Failures"`
|
|
||||||
CertificateAuthentications float64 `perflib:"Certificate Authentications"`
|
|
||||||
DeviceAuthentications float64 `perflib:"Device Authentications"`
|
|
||||||
ExtranetAccountLockouts float64 `perflib:"Extranet Account Lockouts"`
|
|
||||||
FederatedAuthentications float64 `perflib:"Federated Authentications"`
|
|
||||||
PassportAuthentications float64 `perflib:"Microsoft Passport Authentications"`
|
|
||||||
PassiveRequests float64 `perflib:"Passive Requests"`
|
|
||||||
PasswordChangeFailed float64 `perflib:"Password Change Failed Requests"`
|
|
||||||
PasswordChangeSucceeded float64 `perflib:"Password Change Successful Requests"`
|
|
||||||
TokenRequests float64 `perflib:"Token Requests"`
|
|
||||||
WindowsIntegratedAuthentications float64 `perflib:"Windows Integrated Authentications"`
|
|
||||||
OAuthAuthZRequests float64 `perflib:"OAuth AuthZ Requests"`
|
|
||||||
OAuthClientAuthentications float64 `perflib:"OAuth Client Authentications"`
|
|
||||||
OAuthClientAuthenticationFailures float64 `perflib:"OAuth Client Authentications Failures"`
|
|
||||||
OAuthClientCredentialRequestFailures float64 `perflib:"OAuth Client Credentials Request Failures"`
|
|
||||||
OAuthClientCredentialRequests float64 `perflib:"OAuth Client Credentials Requests"`
|
|
||||||
OAuthClientPrivKeyJWTAuthnFailures float64 `perflib:"OAuth Client Private Key Jwt Authentication Failures"`
|
|
||||||
OAuthClientPrivKeyJWTAuthentications float64 `perflib:"OAuth Client Private Key Jwt Authentications"`
|
|
||||||
OAuthClientBasicAuthnFailures float64 `perflib:"OAuth Client Secret Basic Authentication Failures"`
|
|
||||||
OAuthClientBasicAuthentications float64 `perflib:"OAuth Client Secret Basic Authentication Requests"`
|
|
||||||
OAuthClientSecretPostAuthnFailures float64 `perflib:"OAuth Client Secret Post Authentication Failures"`
|
|
||||||
OAuthClientSecretPostAuthentications float64 `perflib:"OAuth Client Secret Post Authentications"`
|
|
||||||
OAuthClientWindowsAuthnFailures float64 `perflib:"OAuth Client Windows Integrated Authentication Failures"`
|
|
||||||
OAuthClientWindowsAuthentications float64 `perflib:"OAuth Client Windows Integrated Authentications"`
|
|
||||||
OAuthLogonCertRequestFailures float64 `perflib:"OAuth Logon Certificate Request Failures"`
|
|
||||||
OAuthLogonCertTokenRequests float64 `perflib:"OAuth Logon Certificate Token Requests"`
|
|
||||||
OAuthPasswordGrantRequestFailures float64 `perflib:"OAuth Password Grant Request Failures"`
|
|
||||||
OAuthPasswordGrantRequests float64 `perflib:"OAuth Password Grant Requests"`
|
|
||||||
OAuthTokenRequests float64 `perflib:"OAuth Token Requests"`
|
|
||||||
SAMLPTokenRequests float64 `perflib:"SAML-P Token Requests"`
|
|
||||||
SSOAuthenticationFailures float64 `perflib:"SSO Authentication Failures"`
|
|
||||||
SSOAuthentications float64 `perflib:"SSO Authentications"`
|
|
||||||
WSFedTokenRequests float64 `perflib:"WS-Fed Token Requests"`
|
|
||||||
WSTrustTokenRequests float64 `perflib:"WS-Trust Token Requests"`
|
|
||||||
UsernamePasswordAuthnFailures float64 `perflib:"U/P Authentication Failures"`
|
|
||||||
UsernamePasswordAuthentications float64 `perflib:"U/P Authentications"`
|
|
||||||
ExternalAuthentications float64 `perflib:"External Authentications"`
|
|
||||||
ExternalAuthNFailures float64 `perflib:"External Authentication Failures"`
|
|
||||||
ArtifactDBFailures float64 `perflib:"Artifact Database Connection Failures"`
|
|
||||||
AvgArtifactDBQueryTime float64 `perflib:"Average Artifact Database Query Time"`
|
|
||||||
ConfigDBFailures float64 `perflib:"Configuration Database Connection Failures"`
|
|
||||||
AvgConfigDBQueryTime float64 `perflib:"Average Config Database Query Time"`
|
|
||||||
FederationMetadataRequests float64 `perflib:"Federation Metadata Requests"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||||
|
if utils.PDHEnabled() {
|
||||||
|
return c.collectPDH(ch)
|
||||||
|
}
|
||||||
|
|
||||||
logger = logger.With(slog.String("collector", Name))
|
logger = logger.With(slog.String("collector", Name))
|
||||||
|
|
||||||
|
return c.collect(ctx, logger, ch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collect(ctx *types.ScrapeContext, logger *slog.Logger, ch chan<- prometheus.Metric) error {
|
||||||
var adfsData []perflibADFS
|
var adfsData []perflibADFS
|
||||||
|
|
||||||
err := perflib.UnmarshalObject(ctx.PerfObjects["AD FS"], &adfsData, logger)
|
err := perflib.UnmarshalObject(ctx.PerfObjects["AD FS"], &adfsData, logger)
|
||||||
@@ -607,13 +634,13 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch ch
|
|||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.wsfedTokenRequests,
|
c.wsFedTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[0].WSFedTokenRequests,
|
adfsData[0].WSFedTokenRequests,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.wstrustTokenRequests,
|
c.wsTrustTokenRequests,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
adfsData[0].WSTrustTokenRequests,
|
adfsData[0].WSTrustTokenRequests,
|
||||||
)
|
)
|
||||||
@@ -674,3 +701,276 @@ func (c *Collector) Collect(ctx *types.ScrapeContext, logger *slog.Logger, ch ch
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||||
|
data, err := c.perfDataCollector.Collect()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to collect Certification Authority (ADCS) metrics: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
adfsData, ok := data[perfdata.EmptyInstance]
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return errors.New("perflib query for Certification Authority (ADCS) returned empty result set")
|
||||||
|
}
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.adLoginConnectionFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[adLoginConnectionFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.certificateAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[certificateAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.deviceAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[deviceAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.extranetAccountLockouts,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[extranetAccountLockouts].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.federatedAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[federatedAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.passportAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[passportAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.passiveRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[passiveRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.passwordChangeFailed,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[passwordChangeFailed].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.passwordChangeSucceeded,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[passwordChangeSucceeded].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.tokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[tokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.windowsIntegratedAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[windowsIntegratedAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthAuthZRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthAuthZRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientAuthenticationsFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientCredentialsRequestFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientCredentialRequestFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientCredentialsRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientCredentialRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientPrivateKeyJwtAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientPrivateKeyJWTAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientPrivateKeyJwtAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientPrivateKeyJWTAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientSecretBasicAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientBasicAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientSecretBasicAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientBasicAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientSecretPostAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientSecretPostAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientSecretPostAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientSecretPostAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientWindowsIntegratedAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientWindowsAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthClientWindowsIntegratedAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthClientWindowsAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthLogonCertificateRequestFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthLogonCertRequestFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthLogonCertificateTokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthLogonCertTokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthPasswordGrantRequestFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthPasswordGrantRequestFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthPasswordGrantRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthPasswordGrantRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.oAuthTokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[oAuthTokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.samlPTokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[samlPTokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.ssoAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[ssoAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.ssoAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[ssoAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.wsFedTokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[wsFedTokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.wsTrustTokenRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[wsTrustTokenRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.upAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[usernamePasswordAuthenticationFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.upAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[usernamePasswordAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.externalAuthenticationFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[externalAuthNFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.externalAuthentications,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[externalAuthentications].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.artifactDBFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[artifactDBFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.avgArtifactDBQueryTime,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[avgArtifactDBQueryTime].FirstValue*math.Pow(10, -8),
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.configDBFailures,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[configDBFailures].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.avgConfigDBQueryTime,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[avgConfigDBQueryTime].FirstValue*math.Pow(10, -8),
|
||||||
|
)
|
||||||
|
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.federationMetadataRequests,
|
||||||
|
prometheus.CounterValue,
|
||||||
|
adfsData[federationMetadataRequests].FirstValue,
|
||||||
|
)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|||||||
93
pkg/collector/adfs/const.go
Normal file
93
pkg/collector/adfs/const.go
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package adfs
|
||||||
|
|
||||||
|
const (
|
||||||
|
adLoginConnectionFailures = "AD Login Connection Failures"
|
||||||
|
artifactDBFailures = "Artifact Database Connection Failures"
|
||||||
|
avgArtifactDBQueryTime = "Average Artifact Database Query Time"
|
||||||
|
avgConfigDBQueryTime = "Average Config Database Query Time"
|
||||||
|
certificateAuthentications = "Certificate Authentications"
|
||||||
|
configDBFailures = "Configuration Database Connection Failures"
|
||||||
|
deviceAuthentications = "Device Authentications"
|
||||||
|
externalAuthentications = "External Authentications"
|
||||||
|
externalAuthNFailures = "External Authentication Failures"
|
||||||
|
extranetAccountLockouts = "Extranet Account Lockouts"
|
||||||
|
federatedAuthentications = "Federated Authentications"
|
||||||
|
federationMetadataRequests = "Federation Metadata Requests"
|
||||||
|
oAuthAuthZRequests = "OAuth AuthZ Requests"
|
||||||
|
oAuthClientAuthenticationFailures = "OAuth Client Authentications Failures"
|
||||||
|
oAuthClientAuthentications = "OAuth Client Authentications"
|
||||||
|
oAuthClientBasicAuthenticationFailures = "OAuth Client Secret Basic Authentication Failures"
|
||||||
|
oAuthClientBasicAuthentications = "OAuth Client Secret Basic Authentication Requests"
|
||||||
|
oAuthClientCredentialRequestFailures = "OAuth Client Credentials Request Failures"
|
||||||
|
oAuthClientCredentialRequests = "OAuth Client Credentials Requests"
|
||||||
|
oAuthClientPrivateKeyJWTAuthenticationFailures = "OAuth Client Private Key Jwt Authentication Failures"
|
||||||
|
oAuthClientPrivateKeyJWTAuthentications = "OAuth Client Private Key Jwt Authentications"
|
||||||
|
oAuthClientSecretPostAuthenticationFailures = "OAuth Client Secret Post Authentication Failures"
|
||||||
|
oAuthClientSecretPostAuthentications = "OAuth Client Secret Post Authentications"
|
||||||
|
oAuthClientWindowsAuthenticationFailures = "OAuth Client Windows Integrated Authentication Failures"
|
||||||
|
oAuthClientWindowsAuthentications = "OAuth Client Windows Integrated Authentications"
|
||||||
|
oAuthLogonCertRequestFailures = "OAuth Logon Certificate Request Failures"
|
||||||
|
oAuthLogonCertTokenRequests = "OAuth Logon Certificate Token Requests"
|
||||||
|
oAuthPasswordGrantRequestFailures = "OAuth Password Grant Request Failures"
|
||||||
|
oAuthPasswordGrantRequests = "OAuth Password Grant Requests"
|
||||||
|
oAuthTokenRequests = "OAuth Token Requests"
|
||||||
|
passiveRequests = "Passive Requests"
|
||||||
|
passportAuthentications = "Microsoft Passport Authentications"
|
||||||
|
passwordChangeFailed = "Password Change Failed Requests"
|
||||||
|
passwordChangeSucceeded = "Password Change Successful Requests"
|
||||||
|
samlPTokenRequests = "SAML-P Token Requests"
|
||||||
|
ssoAuthenticationFailures = "SSO Authentication Failures"
|
||||||
|
ssoAuthentications = "SSO Authentications"
|
||||||
|
tokenRequests = "Token Requests"
|
||||||
|
usernamePasswordAuthenticationFailures = "U/P Authentication Failures"
|
||||||
|
usernamePasswordAuthentications = "U/P Authentications"
|
||||||
|
windowsIntegratedAuthentications = "Windows Integrated Authentications"
|
||||||
|
wsFedTokenRequests = "WS-Fed Token Requests"
|
||||||
|
wsTrustTokenRequests = "WS-Trust Token Requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
type perflibADFS struct {
|
||||||
|
AdLoginConnectionFailures float64 `perflib:"AD Login Connection Failures"`
|
||||||
|
CertificateAuthentications float64 `perflib:"Certificate Authentications"`
|
||||||
|
DeviceAuthentications float64 `perflib:"Device Authentications"`
|
||||||
|
ExtranetAccountLockouts float64 `perflib:"Extranet Account Lockouts"`
|
||||||
|
FederatedAuthentications float64 `perflib:"Federated Authentications"`
|
||||||
|
PassportAuthentications float64 `perflib:"Microsoft Passport Authentications"`
|
||||||
|
PassiveRequests float64 `perflib:"Passive Requests"`
|
||||||
|
PasswordChangeFailed float64 `perflib:"Password Change Failed Requests"`
|
||||||
|
PasswordChangeSucceeded float64 `perflib:"Password Change Successful Requests"`
|
||||||
|
TokenRequests float64 `perflib:"Token Requests"`
|
||||||
|
WindowsIntegratedAuthentications float64 `perflib:"Windows Integrated Authentications"`
|
||||||
|
OAuthAuthZRequests float64 `perflib:"OAuth AuthZ Requests"`
|
||||||
|
OAuthClientAuthentications float64 `perflib:"OAuth Client Authentications"`
|
||||||
|
OAuthClientAuthenticationFailures float64 `perflib:"OAuth Client Authentications Failures"`
|
||||||
|
OAuthClientCredentialRequestFailures float64 `perflib:"OAuth Client Credentials Request Failures"`
|
||||||
|
OAuthClientCredentialRequests float64 `perflib:"OAuth Client Credentials Requests"`
|
||||||
|
OAuthClientPrivKeyJWTAuthnFailures float64 `perflib:"OAuth Client Private Key Jwt Authentication Failures"`
|
||||||
|
OAuthClientPrivKeyJWTAuthentications float64 `perflib:"OAuth Client Private Key Jwt Authentications"`
|
||||||
|
OAuthClientBasicAuthnFailures float64 `perflib:"OAuth Client Secret Basic Authentication Failures"`
|
||||||
|
OAuthClientBasicAuthentications float64 `perflib:"OAuth Client Secret Basic Authentication Requests"`
|
||||||
|
OAuthClientSecretPostAuthnFailures float64 `perflib:"OAuth Client Secret Post Authentication Failures"`
|
||||||
|
OAuthClientSecretPostAuthentications float64 `perflib:"OAuth Client Secret Post Authentications"`
|
||||||
|
OAuthClientWindowsAuthnFailures float64 `perflib:"OAuth Client Windows Integrated Authentication Failures"`
|
||||||
|
OAuthClientWindowsAuthentications float64 `perflib:"OAuth Client Windows Integrated Authentications"`
|
||||||
|
OAuthLogonCertRequestFailures float64 `perflib:"OAuth Logon Certificate Request Failures"`
|
||||||
|
OAuthLogonCertTokenRequests float64 `perflib:"OAuth Logon Certificate Token Requests"`
|
||||||
|
OAuthPasswordGrantRequestFailures float64 `perflib:"OAuth Password Grant Request Failures"`
|
||||||
|
OAuthPasswordGrantRequests float64 `perflib:"OAuth Password Grant Requests"`
|
||||||
|
OAuthTokenRequests float64 `perflib:"OAuth Token Requests"`
|
||||||
|
SAMLPTokenRequests float64 `perflib:"SAML-P Token Requests"`
|
||||||
|
SSOAuthenticationFailures float64 `perflib:"SSO Authentication Failures"`
|
||||||
|
SSOAuthentications float64 `perflib:"SSO Authentications"`
|
||||||
|
WSFedTokenRequests float64 `perflib:"WS-Fed Token Requests"`
|
||||||
|
WSTrustTokenRequests float64 `perflib:"WS-Trust Token Requests"`
|
||||||
|
UsernamePasswordAuthnFailures float64 `perflib:"U/P Authentication Failures"`
|
||||||
|
UsernamePasswordAuthentications float64 `perflib:"U/P Authentications"`
|
||||||
|
ExternalAuthentications float64 `perflib:"External Authentications"`
|
||||||
|
ExternalAuthNFailures float64 `perflib:"External Authentication Failures"`
|
||||||
|
ArtifactDBFailures float64 `perflib:"Artifact Database Connection Failures"`
|
||||||
|
AvgArtifactDBQueryTime float64 `perflib:"Average Artifact Database Query Time"`
|
||||||
|
ConfigDBFailures float64 `perflib:"Configuration Database Connection Failures"`
|
||||||
|
AvgConfigDBQueryTime float64 `perflib:"Average Config Database Query Time"`
|
||||||
|
FederationMetadataRequests float64 `perflib:"Federation Metadata Requests"`
|
||||||
|
}
|
||||||
@@ -2,29 +2,29 @@ package cpu
|
|||||||
|
|
||||||
// Processor performance counters.
|
// Processor performance counters.
|
||||||
const (
|
const (
|
||||||
C1TimeSeconds = "% C1 Time"
|
c1TimeSeconds = "% C1 Time"
|
||||||
C2TimeSeconds = "% C2 Time"
|
c2TimeSeconds = "% C2 Time"
|
||||||
C3TimeSeconds = "% C3 Time"
|
c3TimeSeconds = "% C3 Time"
|
||||||
C1TransitionsTotal = "C1 Transitions/sec"
|
c1TransitionsTotal = "C1 Transitions/sec"
|
||||||
C2TransitionsTotal = "C2 Transitions/sec"
|
c2TransitionsTotal = "C2 Transitions/sec"
|
||||||
C3TransitionsTotal = "C3 Transitions/sec"
|
c3TransitionsTotal = "C3 Transitions/sec"
|
||||||
ClockInterruptsTotal = "Clock Interrupts/sec"
|
clockInterruptsTotal = "Clock Interrupts/sec"
|
||||||
DPCsQueuedTotal = "DPCs Queued/sec"
|
dpcQueuedPerSecond = "DPCs Queued/sec"
|
||||||
DPCTimeSeconds = "% DPC Time"
|
dpcTimeSeconds = "% DPC Time"
|
||||||
IdleBreakEventsTotal = "Idle Break Events/sec"
|
idleBreakEventsTotal = "Idle Break Events/sec"
|
||||||
IdleTimeSeconds = "% Idle Time"
|
idleTimeSeconds = "% Idle Time"
|
||||||
InterruptsTotal = "Interrupts/sec"
|
interruptsTotal = "Interrupts/sec"
|
||||||
InterruptTimeSeconds = "% Interrupt Time"
|
interruptTimeSeconds = "% Interrupt Time"
|
||||||
ParkingStatus = "Parking Status"
|
parkingStatus = "Parking Status"
|
||||||
PerformanceLimitPercent = "% Performance Limit"
|
performanceLimitPercent = "% Performance Limit"
|
||||||
PriorityTimeSeconds = "% Priority Time"
|
priorityTimeSeconds = "% Priority Time"
|
||||||
PrivilegedTimeSeconds = "% Privileged Time"
|
privilegedTimeSeconds = "% Privileged Time"
|
||||||
PrivilegedUtilitySeconds = "% Privileged Utility"
|
privilegedUtilitySeconds = "% Privileged Utility"
|
||||||
ProcessorFrequencyMHz = "Processor Frequency"
|
processorFrequencyMHz = "Processor Frequency"
|
||||||
ProcessorPerformance = "% Processor Performance"
|
processorPerformance = "% Processor Performance"
|
||||||
ProcessorTimeSeconds = "% Processor Time"
|
processorTimeSeconds = "% Processor Time"
|
||||||
ProcessorUtilityRate = "% Processor Utility"
|
processorUtilityRate = "% Processor Utility"
|
||||||
UserTimeSeconds = "% User Time"
|
userTimeSeconds = "% User Time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type perflibProcessorInformation struct {
|
type perflibProcessorInformation struct {
|
||||||
|
|||||||
@@ -78,29 +78,29 @@ func (c *Collector) Close(_ *slog.Logger) error {
|
|||||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||||
if utils.PDHEnabled() {
|
if utils.PDHEnabled() {
|
||||||
counters := []string{
|
counters := []string{
|
||||||
C1TimeSeconds,
|
c1TimeSeconds,
|
||||||
C2TimeSeconds,
|
c2TimeSeconds,
|
||||||
C3TimeSeconds,
|
c3TimeSeconds,
|
||||||
C1TransitionsTotal,
|
c1TransitionsTotal,
|
||||||
C2TransitionsTotal,
|
c2TransitionsTotal,
|
||||||
C3TransitionsTotal,
|
c3TransitionsTotal,
|
||||||
ClockInterruptsTotal,
|
clockInterruptsTotal,
|
||||||
DPCsQueuedTotal,
|
dpcQueuedPerSecond,
|
||||||
DPCTimeSeconds,
|
dpcTimeSeconds,
|
||||||
IdleBreakEventsTotal,
|
idleBreakEventsTotal,
|
||||||
IdleTimeSeconds,
|
idleTimeSeconds,
|
||||||
InterruptsTotal,
|
interruptsTotal,
|
||||||
InterruptTimeSeconds,
|
interruptTimeSeconds,
|
||||||
ParkingStatus,
|
parkingStatus,
|
||||||
PerformanceLimitPercent,
|
performanceLimitPercent,
|
||||||
PriorityTimeSeconds,
|
priorityTimeSeconds,
|
||||||
PrivilegedTimeSeconds,
|
privilegedTimeSeconds,
|
||||||
PrivilegedUtilitySeconds,
|
privilegedUtilitySeconds,
|
||||||
ProcessorFrequencyMHz,
|
processorFrequencyMHz,
|
||||||
ProcessorPerformance,
|
processorPerformance,
|
||||||
ProcessorTimeSeconds,
|
processorTimeSeconds,
|
||||||
ProcessorUtilityRate,
|
processorUtilityRate,
|
||||||
UserTimeSeconds,
|
userTimeSeconds,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -396,119 +396,119 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[C1TimeSeconds].FirstValue,
|
coreData[c1TimeSeconds].FirstValue,
|
||||||
core, "c1",
|
core, "c1",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[C2TimeSeconds].FirstValue,
|
coreData[c2TimeSeconds].FirstValue,
|
||||||
core, "c2",
|
core, "c2",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.cStateSecondsTotal,
|
c.cStateSecondsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[C3TimeSeconds].FirstValue,
|
coreData[c3TimeSeconds].FirstValue,
|
||||||
core, "c3",
|
core, "c3",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[IdleTimeSeconds].FirstValue,
|
coreData[idleTimeSeconds].FirstValue,
|
||||||
core, "idle",
|
core, "idle",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[InterruptTimeSeconds].FirstValue,
|
coreData[interruptTimeSeconds].FirstValue,
|
||||||
core, "interrupt",
|
core, "interrupt",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[DPCTimeSeconds].FirstValue,
|
coreData[dpcTimeSeconds].FirstValue,
|
||||||
core, "dpc",
|
core, "dpc",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[PrivilegedTimeSeconds].FirstValue,
|
coreData[privilegedTimeSeconds].FirstValue,
|
||||||
core, "privileged",
|
core, "privileged",
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.timeTotal,
|
c.timeTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[UserTimeSeconds].FirstValue,
|
coreData[userTimeSeconds].FirstValue,
|
||||||
core, "user",
|
core, "user",
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.interruptsTotal,
|
c.interruptsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[InterruptsTotal].FirstValue,
|
coreData[interruptsTotal].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.dpcsTotal,
|
c.dpcsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[DPCsQueuedTotal].FirstValue,
|
coreData[dpcQueuedPerSecond].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.clockInterruptsTotal,
|
c.clockInterruptsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[ClockInterruptsTotal].FirstValue,
|
coreData[clockInterruptsTotal].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.idleBreakEventsTotal,
|
c.idleBreakEventsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[IdleBreakEventsTotal].FirstValue,
|
coreData[idleBreakEventsTotal].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.parkingStatus,
|
c.parkingStatus,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
coreData[ParkingStatus].FirstValue,
|
coreData[parkingStatus].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
|
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorFrequencyMHz,
|
c.processorFrequencyMHz,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
coreData[ProcessorFrequencyMHz].FirstValue,
|
coreData[processorFrequencyMHz].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPerformance,
|
c.processorPerformance,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[ProcessorPerformance].FirstValue,
|
coreData[processorPerformance].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorMPerf,
|
c.processorMPerf,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[ProcessorPerformance].SecondValue,
|
coreData[processorPerformance].SecondValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorRTC,
|
c.processorRTC,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[ProcessorUtilityRate].SecondValue,
|
coreData[processorUtilityRate].SecondValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorUtility,
|
c.processorUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[ProcessorUtilityRate].FirstValue,
|
coreData[processorUtilityRate].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.processorPrivilegedUtility,
|
c.processorPrivilegedUtility,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
coreData[PrivilegedUtilitySeconds].FirstValue,
|
coreData[privilegedUtilitySeconds].FirstValue,
|
||||||
core,
|
core,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ package tcp
|
|||||||
// - https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx
|
// - https://msdn.microsoft.com/en-us/library/aa394341(v=vs.85).aspx
|
||||||
// The TCPv6 performance object uses the same fields.
|
// The TCPv6 performance object uses the same fields.
|
||||||
const (
|
const (
|
||||||
ConnectionFailures = "Connection Failures"
|
connectionFailures = "Connection Failures"
|
||||||
ConnectionsActive = "Connections Active"
|
connectionsActive = "Connections Active"
|
||||||
ConnectionsEstablished = "Connections Established"
|
connectionsEstablished = "Connections Established"
|
||||||
ConnectionsPassive = "Connections Passive"
|
connectionsPassive = "Connections Passive"
|
||||||
ConnectionsReset = "Connections Reset"
|
connectionsReset = "Connections Reset"
|
||||||
SegmentsPersec = "Segments/sec"
|
segmentsPerSec = "Segments/sec"
|
||||||
SegmentsReceivedPersec = "Segments Received/sec"
|
segmentsReceivedPerSec = "Segments Received/sec"
|
||||||
SegmentsRetransmittedPersec = "Segments Retransmitted/sec"
|
segmentsRetransmittedPerSec = "Segments Retransmitted/sec"
|
||||||
SegmentsSentPersec = "Segments Sent/sec"
|
segmentsSentPerSec = "Segments Sent/sec"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -67,15 +67,15 @@ func (c *Collector) Close(_ *slog.Logger) error {
|
|||||||
|
|
||||||
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
func (c *Collector) Build(_ *slog.Logger, _ *wmi.Client) error {
|
||||||
counters := []string{
|
counters := []string{
|
||||||
ConnectionFailures,
|
connectionFailures,
|
||||||
ConnectionsActive,
|
connectionsActive,
|
||||||
ConnectionsEstablished,
|
connectionsEstablished,
|
||||||
ConnectionsPassive,
|
connectionsPassive,
|
||||||
ConnectionsReset,
|
connectionsReset,
|
||||||
SegmentsPersec,
|
segmentsPerSec,
|
||||||
SegmentsReceivedPersec,
|
segmentsReceivedPerSec,
|
||||||
SegmentsRetransmittedPersec,
|
segmentsRetransmittedPerSec,
|
||||||
SegmentsSentPersec,
|
segmentsSentPerSec,
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
@@ -167,55 +167,55 @@ func writeTCPCounters(metrics map[string]perfdata.CounterValues, labels []string
|
|||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionFailures,
|
c.connectionFailures,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[ConnectionFailures].FirstValue,
|
metrics[connectionFailures].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsActive,
|
c.connectionsActive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[ConnectionsActive].FirstValue,
|
metrics[connectionsActive].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsEstablished,
|
c.connectionsEstablished,
|
||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
metrics[ConnectionsEstablished].FirstValue,
|
metrics[connectionsEstablished].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsPassive,
|
c.connectionsPassive,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[ConnectionsPassive].FirstValue,
|
metrics[connectionsPassive].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.connectionsReset,
|
c.connectionsReset,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[ConnectionsReset].FirstValue,
|
metrics[connectionsReset].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsTotal,
|
c.segmentsTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[SegmentsPersec].FirstValue,
|
metrics[segmentsPerSec].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsReceivedTotal,
|
c.segmentsReceivedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[SegmentsReceivedPersec].FirstValue,
|
metrics[segmentsReceivedPerSec].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsRetransmittedTotal,
|
c.segmentsRetransmittedTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[SegmentsRetransmittedPersec].FirstValue,
|
metrics[segmentsRetransmittedPerSec].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
ch <- prometheus.MustNewConstMetric(
|
ch <- prometheus.MustNewConstMetric(
|
||||||
c.segmentsSentTotal,
|
c.segmentsSentTotal,
|
||||||
prometheus.CounterValue,
|
prometheus.CounterValue,
|
||||||
metrics[SegmentsSentPersec].FirstValue,
|
metrics[segmentsSentPerSec].FirstValue,
|
||||||
labels...,
|
labels...,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user