-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1862 from swisscom/feature/aws-api-call-metrics
- Loading branch information
Showing
5 changed files
with
58 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
||
k8smetrics "sigs.k8s.io/controller-runtime/pkg/metrics" | ||
) | ||
|
||
var ( | ||
metricAWSAPICalls = prometheus.NewCounterVec(prometheus.CounterOpts{ | ||
Name: "aws_api_calls_total", | ||
Help: "Number of API calls to the AWS API", | ||
}, []string{"service", "operation", "api_version"}) | ||
) | ||
|
||
// SetupMetrics will register the known Prometheus metrics with controller-runtime's metrics registry | ||
func SetupMetrics() error { | ||
return k8smetrics.Registry.Register(metricAWSAPICalls) | ||
} | ||
|
||
// IncAWSAPICall will increment the aws_api_calls_total metric for the specified service, operation, and apiVersion tuple | ||
func IncAWSAPICall(service, operation, apiVersion string) { | ||
metricAWSAPICalls.WithLabelValues(service, operation, apiVersion).Inc() | ||
} |