mirror of
https://github.com/kubernetes-sigs/external-dns.git
synced 2025-08-06 01:26:59 +02:00
webhook: Fix metric name and add request gauges
Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
parent
af8b5d875e
commit
540990e00c
12
docs/faq.md
12
docs/faq.md
@ -194,6 +194,18 @@ Here is the full list of available metrics provided by ExternalDNS:
|
||||
| external_dns_source_a_records | Number of A records in source | Gauge |
|
||||
|
||||
|
||||
If you're using the webhook provider, the following additional metrics will be provided:
|
||||
|
||||
| Name | Description | Type |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------ | ------- |
|
||||
| external_dns_webhook_provider_records_errors_total | Number of errors with the /records method | Gauge |
|
||||
| external_dns_webhook_provider_records_requests_total | Number of requests made to the /records method | Gauge |
|
||||
| external_dns_webhook_provider_applychanges_errors_total | Number of errors with the /applychanges method | Gauge |
|
||||
| external_dns_webhook_provider_applychanges_requests_total | Number of requests made to the /applychanges method | Gauge |
|
||||
| external_dns_webhook_provider_adjustendpoints_errors_total | Number of errors with the /adjustendpoints method | Gauge |
|
||||
| external_dns_webhook_provider_adjustendpoints_requests_total | Number of requests made to the /adjustendpoints method | Gauge |
|
||||
|
||||
|
||||
### How can I run ExternalDNS under a specific GCP Service Account, e.g. to access DNS records in other projects?
|
||||
|
||||
Have a look at https://github.com/linki/mate/blob/v0.6.2/examples/google/README.md#permissions
|
||||
|
@ -43,26 +43,50 @@ var (
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "records_errors",
|
||||
Name: "records_errors_total",
|
||||
Help: "Errors with Records method",
|
||||
},
|
||||
)
|
||||
recordsRequestsGauge = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "records_requests_total",
|
||||
Help: "Requests with Records method",
|
||||
},
|
||||
)
|
||||
applyChangesErrorsGauge = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "applychanges_errors",
|
||||
Name: "applychanges_errors_total",
|
||||
Help: "Errors with ApplyChanges method",
|
||||
},
|
||||
)
|
||||
applyChangesRequestsGauge = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "applychanges_requests_total",
|
||||
Help: "Requests with ApplyChanges method",
|
||||
},
|
||||
)
|
||||
adjustEndpointsErrorsGauge = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "adjustendpointsgauge_errors",
|
||||
Name: "adjustendpoints_errors_total",
|
||||
Help: "Errors with AdjustEndpoints method",
|
||||
},
|
||||
)
|
||||
adjustEndpointsRequestsGauge = prometheus.NewGauge(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: "external_dns",
|
||||
Subsystem: "webhook_provider",
|
||||
Name: "adjustendpoints_requests_total",
|
||||
Help: "Requests with AdjustEndpoints method",
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
type WebhookProvider struct {
|
||||
@ -73,8 +97,11 @@ type WebhookProvider struct {
|
||||
|
||||
func init() {
|
||||
prometheus.MustRegister(recordsErrorsGauge)
|
||||
prometheus.MustRegister(recordsRequestsGauge)
|
||||
prometheus.MustRegister(applyChangesErrorsGauge)
|
||||
prometheus.MustRegister(applyChangesRequestsGauge)
|
||||
prometheus.MustRegister(adjustEndpointsErrorsGauge)
|
||||
prometheus.MustRegister(adjustEndpointsRequestsGauge)
|
||||
}
|
||||
|
||||
func NewWebhookProvider(u string) (*WebhookProvider, error) {
|
||||
@ -132,7 +159,9 @@ func NewWebhookProvider(u string) (*WebhookProvider, error) {
|
||||
|
||||
// Records will make a GET call to remoteServerURL/records and return the results
|
||||
func (p WebhookProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, error) {
|
||||
recordsRequestsGauge.Inc()
|
||||
u := p.remoteServerURL.JoinPath("records").String()
|
||||
|
||||
req, err := http.NewRequest("GET", u, nil)
|
||||
if err != nil {
|
||||
recordsErrorsGauge.Inc()
|
||||
@ -165,6 +194,7 @@ func (p WebhookProvider) Records(ctx context.Context) ([]*endpoint.Endpoint, err
|
||||
|
||||
// ApplyChanges will make a POST to remoteServerURL/records with the changes
|
||||
func (p WebhookProvider) ApplyChanges(ctx context.Context, changes *plan.Changes) error {
|
||||
applyChangesRequestsGauge.Inc()
|
||||
u := p.remoteServerURL.JoinPath("records").String()
|
||||
|
||||
b := new(bytes.Buffer)
|
||||
@ -203,6 +233,7 @@ func (p WebhookProvider) ApplyChanges(ctx context.Context, changes *plan.Changes
|
||||
// based on a provider specific requirement.
|
||||
// This method returns an empty slice in case there is a technical error on the provider's side so that no endpoints will be considered.
|
||||
func (p WebhookProvider) AdjustEndpoints(e []*endpoint.Endpoint) ([]*endpoint.Endpoint, error) {
|
||||
adjustEndpointsRequestsGauge.Inc()
|
||||
endpoints := []*endpoint.Endpoint{}
|
||||
u, err := url.JoinPath(p.remoteServerURL.String(), "adjustendpoints")
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user