From 5e9df54372c6d1115abb5bb0a7e6b3fb86e6b03e Mon Sep 17 00:00:00 2001 From: kgeckhart Date: Thu, 21 Dec 2023 12:46:28 -0500 Subject: [PATCH] azure exporter: Enable features from upstream exporter (#5707) * Update azure exporter for ValidateDimension support * Add support for subscription scoped metric gathering * Add docs for validate_dimensions * Fix conditional for when to use subscription scope * changelog entry * Fix crow error from prom common upgrade * Code review feedback * Cleanup merge + missing review comments + fix deprecations from go.mod update --- CHANGELOG.md | 9 ++ component/otelcol/config_filter_test.go | 6 +- component/prometheus/exporter/azure/azure.go | 8 ++ .../internal/build/azure_exporter.go | 2 + .../components/prometheus.exporter.azure.md | 57 +++++++++---- .../integrations/azure-exporter-config.md | 40 +++++++-- go.mod | 42 +++++----- go.sum | 83 ++++++++++--------- .../azure_exporter/azure_exporter.go | 32 +++++-- pkg/integrations/azure_exporter/config.go | 46 +++++++--- .../azure_exporter/config_test.go | 18 +++- pkg/operator/config/config_test.go | 11 +-- pkg/operator/config/metrics_templates_test.go | 15 ++-- pkg/operator/reconciler_metrics.go | 11 +-- pkg/operator/resources_metrics.go | 13 +-- pkg/operator/resources_pod_template.go | 13 +-- .../internal/dtobuilder/dtobuilder.go | 24 +++--- tools/smoke/internal/tasks.go | 6 +- 18 files changed, 287 insertions(+), 149 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52748f243ff5..855f6dd398e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,11 @@ Main (unreleased) - The `target` block in `prometheus.exporter.blackbox` requires a mandatory `name` argument instead of a block label. (@hainenber) +- In the azure exporter, dimension options will no longer be validated by the Azure API. (@kgeckhart) + - This change will not break any existing configurations and you can opt in to validation via the `validate_dimensions` configuration option. + - Before this change, pulling metrics for azure resources with variable dimensions required one configuration per metric + dimension combination to avoid an error. + - After this change, you can include all metrics and dimensions in a single configuration and the Azure APIs will only return dimensions which are valid for the various metrics. + ### Enhancements - Flow Windows service: Support environment variables. (@jkroepke) @@ -63,6 +68,10 @@ Main (unreleased) - Added 'country' mmdb-type to log pipeline-stage geoip. (@superstes) +- Azure exporter enhancements for flow and static mode, (@kgeckhart) + - Allows for pulling metrics at the Azure subscription level instead of resource by resource + - Disable dimension validation by default to reduce the number of exporter instances needed for full dimension coverage + ### Bugfixes - Update `pyroscope.ebpf` to fix a logical bug causing to profile to many kthreads instead of regular processes https://github.com/grafana/pyroscope/pull/2778 (@korniltsev) diff --git a/component/otelcol/config_filter_test.go b/component/otelcol/config_filter_test.go index 9e4eab1ec293..39a1fae4c90a 100644 --- a/component/otelcol/config_filter_test.go +++ b/component/otelcol/config_filter_test.go @@ -3,11 +3,13 @@ package otelcol_test import ( "testing" + "k8s.io/utils/ptr" + "github.com/grafana/agent/component/otelcol" + "github.com/grafana/river" "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/pdata/plog" - "k8s.io/utils/pointer" ) func TestConvertMatchProperties(t *testing.T) { @@ -49,7 +51,7 @@ func TestConvertMatchProperties(t *testing.T) { Libraries: []otelcol.InstrumentationLibrary{ { Name: "mongo-java-driver", - Version: pointer.String("3.8.0"), + Version: ptr.To("3.8.0"), }, }, SpanKinds: []string{"span1"}, diff --git a/component/prometheus/exporter/azure/azure.go b/component/prometheus/exporter/azure/azure.go index 9f454d40ce11..fa51a1ac01b0 100644 --- a/component/prometheus/exporter/azure/azure.go +++ b/component/prometheus/exporter/azure/azure.go @@ -35,6 +35,8 @@ type Arguments struct { MetricNameTemplate string `river:"metric_name_template,attr,optional"` MetricHelpTemplate string `river:"metric_help_template,attr,optional"` AzureCloudEnvironment string `river:"azure_cloud_environment,attr,optional"` + ValidateDimensions bool `river:"validate_dimensions,attr,optional"` + Regions []string `river:"regions,attr,optional"` } var DefaultArguments = Arguments{ @@ -43,6 +45,10 @@ var DefaultArguments = Arguments{ MetricHelpTemplate: "Azure metric {metric} for {type} with aggregation {aggregation} as {unit}", IncludedResourceTags: []string{"owner"}, AzureCloudEnvironment: "azurecloud", + // Dimensions do not always apply to all metrics for a service, which requires you to configure multiple exporters + // to fully monitor a service which is tedious. Turning off validation eliminates this complexity. The underlying + // sdk will only give back the dimensions which are valid for particular metrics. + ValidateDimensions: false, } // SetToDefault implements river.Defaulter. @@ -72,5 +78,7 @@ func (a *Arguments) Convert() *azure_exporter.Config { MetricNameTemplate: a.MetricNameTemplate, MetricHelpTemplate: a.MetricHelpTemplate, AzureCloudEnvironment: a.AzureCloudEnvironment, + ValidateDimensions: a.ValidateDimensions, + Regions: a.Regions, } } diff --git a/converter/internal/staticconvert/internal/build/azure_exporter.go b/converter/internal/staticconvert/internal/build/azure_exporter.go index 1a6a39f7c842..b51b36103d44 100644 --- a/converter/internal/staticconvert/internal/build/azure_exporter.go +++ b/converter/internal/staticconvert/internal/build/azure_exporter.go @@ -25,5 +25,7 @@ func toAzureExporter(config *azure_exporter.Config) *azure.Arguments { MetricNameTemplate: config.MetricNameTemplate, MetricHelpTemplate: config.MetricHelpTemplate, AzureCloudEnvironment: config.AzureCloudEnvironment, + ValidateDimensions: config.ValidateDimensions, + Regions: config.Regions, } } diff --git a/docs/sources/flow/reference/components/prometheus.exporter.azure.md b/docs/sources/flow/reference/components/prometheus.exporter.azure.md index 9363067fd0a7..ea8fa08cd912 100644 --- a/docs/sources/flow/reference/components/prometheus.exporter.azure.md +++ b/docs/sources/flow/reference/components/prometheus.exporter.azure.md @@ -11,19 +11,30 @@ title: prometheus.exporter.azure # prometheus.exporter.azure -The `prometheus.exporter.azure` component embeds [`azure-metrics-exporter`](https://github.com/webdevops/azure-metrics-exporter) to collect metrics from [Azure Monitor](https://azure.microsoft.com/en-us/products/monitor). The exporter uses [Azure Resource Graph](https://azure.microsoft.com/en-us/get-started/azure-portal/resource-graph/#overview) queries to identify resources for gathering metrics. +The `prometheus.exporter.azure` component embeds [`azure-metrics-exporter`](https://github.com/webdevops/azure-metrics-exporter) to collect metrics from [Azure Monitor](https://azure.microsoft.com/en-us/products/monitor). The exporter supports all metrics defined by Azure Monitor. You can find the complete list of available metrics in the [Azure Monitor documentation](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported). Metrics for this integration are exposed with the template `azure_{type}_{metric}_{aggregation}_{unit}` by default. As an example, the Egress metric for BlobService would be exported as `azure_microsoft_storage_storageaccounts_blobservices_egress_total_bytes`. +The exporter offers the following two options for gathering metrics. + +1. (Default) Use an [Azure Resource Graph](https://azure.microsoft.com/en-us/get-started/azure-portal/resource-graph/#overview) query to identify resources for gathering metrics. + 1. This query will make one API call per resource identified. + 1. Subscriptions with a reasonable amount of resources can hit the [12000 requests per hour rate limit](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/request-limits-and-throttling#subscription-and-tenant-limits) Azure enforces. +1. Set the regions to gather metrics from and get metrics for all resources across those regions. + 1. This option will make one API call per subscription, dramatically reducing the number of API calls. + 1. This approach does not work with all resource types, and Azure does not document which resource types do or do not work. + 1. A resource type that is not supported produces errors that look like `Resource type: microsoft.containerservice/managedclusters not enabled for Cross Resource metrics`. + 1. If you encounter one of these errors you must use the default Azure Resource Graph based option to gather metrics. + ## Authentication {{< param "PRODUCT_NAME" >}} must be running in an environment with access to Azure. The exporter uses the Azure SDK for go and supports [authentication](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication?tabs=bash#2-authenticate-with-azure). The account used by {{< param "PRODUCT_NAME" >}} needs: -- [Read access to the resources that will be queried by Resource Graph](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview#permissions-in-azure-resource-graph) +- When using an Azure Resource Graph query, [read access to the resources that will be queried by Resource Graph](https://learn.microsoft.com/en-us/azure/governance/resource-graph/overview#permissions-in-azure-resource-graph) - Permissions to call the [Microsoft.Insights Metrics API](https://learn.microsoft.com/en-us/rest/api/monitor/metrics/list) which should be the `Microsoft.Insights/Metrics/Read` permission ## Usage @@ -51,23 +62,27 @@ prometheus.exporter.azure LABEL { You can use the following arguments to configure the exporter's behavior. Omitted fields take their default values. -| Name | Type | Description | Default | Required | -| ----------------------------- | -------------- | -------------------------------------------------------------------- | ----------------------------------------------------------------------------- | -------- | -| `subscriptions` | `list(string)` | List of subscriptions to scrap metrics from. | | yes | -| `resource_type` | `string` | The Azure Resource Type to scrape metrics for. | | yes | -| `metrics` | `list(string)` | The metrics to scrape from resources. | | yes | -| `resource_graph_query_filter` | `string` | The [Kusto query][] filter to apply when searching for resources. | | no | -| `metric_aggregations` | `list(string)` | Aggregations to apply for the metrics produced. | | no | -| `timespan` | `string` | [ISO8601 Duration][] over which the metrics are being queried. | `"PT1M"` (1 minute) | no | -| `included_dimensions` | `list(string)` | List of dimensions to include on the final metrics. | | no | -| `included_resource_tags` | `list(string)` | List of resource tags to include on the final metrics. | `["owner"]` | no | -| `metric_namespace` | `string` | Namespace for `resource_type` which have multiple levels of metrics. | | no | -| `azure_cloud_environment` | `string` | Name of the cloud environment to connect to. | `"azurecloud"` | no | -| `metric_name_template` | `string` | Metric template used to expose the metrics. | `"azure_{type}_{metric}_{aggregation}_{unit}"` | no | -| `metric_help_template` | `string` | Description of the metric. | `"Azure metric {metric} for {type} with aggregation {aggregation} as {unit}"` | no | +| Name | Type | Description | Default | Required | +|-------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|----------| +| `subscriptions` | `list(string)` | List of subscriptions to scrape metrics from. | | yes | +| `resource_type` | `string` | The Azure Resource Type to scrape metrics for. | | yes | +| `metrics` | `list(string)` | The metrics to scrape from resources. | | yes | +| `resource_graph_query_filter` | `string` | The [Kusto query][] filter to apply when searching for resources. Can't be used if `regions` is set. | | no | +| `regions` | `list(string)` | The list of regions for gathering metrics and enables gathering metrics for all resources in the subscription. Can't be used if `resource_graph_query_filter` is set. | | no | +| `metric_aggregations` | `list(string)` | Aggregations to apply for the metrics produced. | | no | +| `timespan` | `string` | [ISO8601 Duration][] over which the metrics are being queried. | `"PT1M"` (1 minute) | no | +| `included_dimensions` | `list(string)` | List of dimensions to include on the final metrics. | | no | +| `included_resource_tags` | `list(string)` | List of resource tags to include on the final metrics. | `["owner"]` | no | +| `metric_namespace` | `string` | Namespace for `resource_type` which have multiple levels of metrics. | | no | +| `azure_cloud_environment` | `string` | Name of the cloud environment to connect to. | `"azurecloud"` | no | +| `metric_name_template` | `string` | Metric template used to expose the metrics. | `"azure_{type}_{metric}_{aggregation}_{unit}"` | no | +| `metric_help_template` | `string` | Description of the metric. | `"Azure metric {metric} for {type} with aggregation {aggregation} as {unit}"` | no | +| `validate_dimensions` | `bool` | Enable dimension validation in the azure sdk | `false` | no | The list of available `resource_type` values and their corresponding `metrics` can be found in [Azure Monitor essentials][]. +The list of available `regions` to your subscription can be found by running the azure CLI command `az account list-locations --query '[].name'`. + The `resource_graph_query_filter` can be embedded into a template query of the form `Resources | where type =~ "" | project id, tags`. Valid values for `metric_aggregations` are `minimum`, `maximum`, `average`, `total`, and `count`. If no aggregation is specified, the value is retrieved from the metric. For example, the aggregation value of the metric `Availability` in [Microsoft.ClassicStorage/storageAccounts](https://learn.microsoft.com/en-us/azure/azure-monitor/reference/supported-metrics/microsoft-classicstorage-storageaccounts-metrics) is `average`. @@ -78,6 +93,8 @@ Tags in `included_resource_tags` will be added as labels with the name `tag_" | project id, tags` + # Can't be used if `regions` is set. [resource_graph_query_filter: ] + + # Optional: The list of regions for gathering metrics. Enables gathering metrics for all resources in the subscription. + # The list of available `regions` to your subscription can be found by running the Azure CLI command `az account list-locations --query '[].name'`. + # Can't be used if `resource_graph_query_filter` is set. + regions: + [ - ... ] # Optional: Aggregation to apply for the metrics produced. Valid values are minimum, maximum, average, total, and count # If no aggregation is specified the value for `Aggregation Type` on the `Metric` is used from https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported @@ -139,6 +155,10 @@ The account used by Grafana Agent needs: # Optional: Which azure cloud environment to connect to, azurecloud, azurechinacloud, azuregovernmentcloud, or azurepprivatecloud [azure_cloud_environment: | default = "azurecloud"] + + # Optional: Validation is disabled by default to reduce the number of Azure exporter instances required when a `resource_type` has metrics with varying dimensions. + # Choosing to enable `validate_dimensions` will require one exporter instance per metric + dimension combination which can be very tedious to maintain. + [validate_dimensions: | default = false] ``` ### Examples @@ -167,6 +187,7 @@ The account used by Grafana Agent needs: included_dimensions: - node - nodepool + - device ``` #### Blob Storage Metrics @@ -178,6 +199,8 @@ The account used by Grafana Agent needs: - resource_type: Microsoft.Storage/storageAccounts metric_namespace: Microsoft.Storage/storageAccounts/blobServices + regions: + - westeurope metrics: - Availability - BlobCapacity @@ -189,8 +212,10 @@ The account used by Grafana Agent needs: - SuccessE2ELatency - SuccessServerLatency - Transactions + included_dimensions: + - ApiName + - TransactionType timespan: PT1H - resource_graph_query_filter: where location == "westeurope" ``` ### Multiple Azure Services in a single config @@ -222,6 +247,8 @@ metrics: subscriptions: - 179c4f30-ebd8-489e-92bc-fb64588dadb3 resource_type: ["Microsoft.Storage/storageAccounts"] + regions: + - westeurope metric_namespace: ["Microsoft.Storage/storageAccounts/blobServices"] metrics: - Availability @@ -234,8 +261,10 @@ metrics: - SuccessE2ELatency - SuccessServerLatency - Transactions + included_dimensions: + - ApiName + - TransactionType timespan: ["PT1H"] - resource_graph_query_filter: ["where location == 'westeurope'"] - job_name: azure-kubernetes-node scrape_interval: 1m scrape_timeout: 50s @@ -263,6 +292,7 @@ metrics: included_dimensions: - node - nodepool + - device ``` In this example, all `azure_exporter`-specific configuration settings have been moved to the `scrape_config`. This method supports all available configuration options except `azure_cloud_environment`, which must be configured on the `azure_exporter`. For this method, if a field supports a singular value like `resource_graph_query_filter`, you diff --git a/go.mod b/go.mod index d4d337035920..4614e9124d44 100644 --- a/go.mod +++ b/go.mod @@ -4,8 +4,8 @@ go 1.21.0 require ( cloud.google.com/go/pubsub v1.33.0 - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0-beta.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/go-autorest/autorest v0.11.29 github.com/IBM/sarama v1.42.1 github.com/Lusitaniae/apache_exporter v0.11.1-0.20220518131644-f9522724dab4 @@ -49,7 +49,7 @@ require ( github.com/google/go-jsonnet v0.18.0 github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 github.com/google/renameio/v2 v2.0.0 - github.com/google/uuid v1.3.1 + github.com/google/uuid v1.4.0 github.com/gorilla/mux v1.8.0 github.com/grafana/ckit v0.0.0-20230906125525-c046c99a5c04 github.com/grafana/cloudflare-go v0.0.0-20230110200409-c627cf6792f2 @@ -149,7 +149,7 @@ require ( github.com/prometheus/memcached_exporter v0.13.0 github.com/prometheus/mysqld_exporter v0.14.0 github.com/prometheus/node_exporter v1.6.0 - github.com/prometheus/procfs v0.11.1 + github.com/prometheus/procfs v0.12.0 github.com/prometheus/prometheus v1.99.0 github.com/prometheus/snmp_exporter v0.24.1 github.com/prometheus/statsd_exporter v0.22.8 @@ -165,8 +165,8 @@ require ( github.com/testcontainers/testcontainers-go/modules/k3s v0.0.0-20230615142642-c175df34bd1d github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/vincent-petithory/dataurl v1.0.0 - github.com/webdevops/azure-metrics-exporter v0.0.0-20230502203721-b2bfd97b5313 - github.com/webdevops/go-common v0.0.0-20230612205735-2ee45347be15 + github.com/webdevops/azure-metrics-exporter v0.0.0-20230717202958-8701afc2b013 + github.com/webdevops/go-common v0.0.0-20231022162947-a6adfb05a7e9 github.com/wk8/go-ordered-map v0.2.0 github.com/xdg-go/scram v1.1.2 github.com/zeebo/xxh3 v1.0.2 @@ -225,13 +225,12 @@ require ( gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools v2.2.0+incompatible - k8s.io/api v0.28.2 + k8s.io/api v0.28.3 k8s.io/apiextensions-apiserver v0.28.0 - k8s.io/apimachinery v0.28.2 - k8s.io/client-go v0.28.2 + k8s.io/client-go v0.28.3 k8s.io/component-base v0.28.1 k8s.io/klog/v2 v2.100.1 - k8s.io/utils v0.0.0-20230711102312-30195339c3c7 + k8s.io/utils v0.0.0-20230726121419-3b25d923346b sigs.k8s.io/controller-runtime v0.16.2 sigs.k8s.io/yaml v1.3.0 ) @@ -246,12 +245,12 @@ require ( github.com/99designs/keyring v1.2.2 // indirect github.com/AlekSi/pointer v1.1.0 // indirect github.com/Azure/azure-sdk-for-go v66.0.0+incompatible // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.9.1 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.7.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.10.2 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.2 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Azure/go-autorest v14.2.0+incompatible // indirect github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect @@ -262,9 +261,8 @@ require ( github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect github.com/Azure/go-autorest/logger v0.2.1 // indirect github.com/Azure/go-autorest/tracing v0.6.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 // indirect github.com/BurntSushi/toml v1.2.1 // indirect - github.com/ChannelMeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 // indirect github.com/ClickHouse/clickhouse-go v1.5.4 // indirect github.com/GehirnInc/crypt v0.0.0-20200316065508-bb7000b8a962 // indirect github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c // indirect @@ -343,7 +341,7 @@ require ( github.com/elastic/go-sysinfo v1.8.1 // indirect github.com/elastic/go-windows v1.0.1 // indirect github.com/ema/qdisc v1.0.0 // indirect - github.com/emicklei/go-restful/v3 v3.10.2 // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect github.com/envoyproxy/go-control-plane v0.11.1 // indirect github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect @@ -590,7 +588,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect gonum.org/v1/gonum v0.14.0 // indirect - google.golang.org/appengine v1.6.7 // indirect + google.golang.org/appengine v1.6.8 // indirect google.golang.org/genproto v0.0.0-20231012201019-e917dd12ba7a // indirect google.golang.org/genproto/googleapis/api v0.0.0-20231002182017-d307bd883b97 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect @@ -601,7 +599,7 @@ require ( gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect howett.net/plist v1.0.0 // indirect - k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect ) @@ -615,15 +613,19 @@ require ( github.com/open-telemetry/opentelemetry-collector-contrib/processor/filterprocessor v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.87.0 github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver v0.87.0 + github.com/prometheus/tsdb v0.10.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v0.42.0 + k8s.io/apimachinery v0.28.3 ) require ( dario.cat/mergo v1.0.0 // indirect github.com/Shopify/sarama v1.38.1 // indirect github.com/Workiva/go-datastructures v1.1.0 // indirect + github.com/channelmeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 // indirect github.com/drone/envsubst v1.0.3 // indirect - github.com/go-jose/go-jose/v3 v3.0.1 // indirect + github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/hetznercloud/hcloud-go/v2 v2.0.0 // indirect github.com/julienschmidt/httprouter v1.3.0 // indirect diff --git a/go.sum b/go.sum index e1ebb63ddbe4..fed259a01614 100644 --- a/go.sum +++ b/go.sum @@ -81,28 +81,30 @@ github.com/Azure/azure-sdk-for-go v36.2.0+incompatible h1:09cv2WoH0g6jl6m2iT+R9q github.com/Azure/azure-sdk-for-go v36.2.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.0.0/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.2/go.mod h1:uGG2W01BaETf0Ozp+QxxKJdMBNRWPdstHG0Fmdwn1/U= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0 h1:8q4SaHjFsClSvuVne0ID/5Ka8u3fcIHyqkLjcFpNRHQ= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0-beta.1 h1:ODs3brnqQM99Tq1PffODpAViYv3Bf8zOg464MU7p5ew= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0-beta.1/go.mod h1:3Ug6Qzto9anB6mGlEdgYMDF5zHQ+wwhEaYR4s17PHMw= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.1.0/go.mod h1:bhXu1AjYL+wutSL/kpSq6s7733q2Rb0yuot9Zgfqa/0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 h1:TuEMD+E+1aTjjLICGQOW6vLe8UWES7kopac9mUXL56Y= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0/go.mod h1:mLfWfj8v3jfWKsL9G4eoBoXVcsqcIUTapmdKy7uGOp0= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.9.1 h1:BDYGHuQZ5IjPpdXcZmFVsXnWOcjZ0+trzyUfiyIDsBU= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.9.1/go.mod h1:Xvhh92LkBGnwklU5WY19Ky2kwZy5bkKqm6+uLT5CGoY= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.7.1 h1:eoQrCw9DMThzbJ32fHXZtISnURk6r0TozXiWuTsay5s= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.7.1/go.mod h1:21rlzm+SuYrS9ARS92XEGxcHQeLVDcaY2YV30rHjSd4= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.10.2 h1:T3P5KJpcgN0m39dhaNM+JjSqF3Z5VqUlKHlth5FgN+8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor v0.10.2/go.mod h1:yA8WUvh3K/SABQEtFHg2Bx5D+414FyFqpT5Fu58P3ao= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.2 h1:f9lam+D19V0TDn17+aFhrVhWPpfsF5zaGHeqDGJZAVc= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph v0.8.2/go.mod h1:29c9+gYpdWhyC4TPANZBPlgoWllMDhguL2AIByPYQtk= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.2.0 h1:Pmy0+3ox1IC3sp6musv87BFPIdQbqyPFjn7I8I0o2Js= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions v1.2.0/go.mod h1:ThfyMjs6auYrWPnYJjI3H4H++oVPrz01pizpu8lfl3A= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0 h1:u/LLAOFgsMv7HmNL4Qufg58y+qElGOt5qv0z1mURkRY= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.0.0/go.mod h1:2e8rMJtl2+2j+HXbTBwnyGpm5Nou7KhvSfxOq8JpTag= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0/go.mod h1:c+Lifp3EDEamAkPVzMooRNOK6CZjNSdEnf1A7jsI9u4= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4= github.com/Azure/azure-storage-queue-go v0.0.0-20181215014128-6ed74e755687/go.mod h1:K6am8mT+5iFXgingS9LUc7TmbsW6XBw3nxaRyaMyWc8= github.com/Azure/go-amqp v0.12.6/go.mod h1:qApuH6OFTSKZFmCOxccvAv5rLizBQf4v8pRmG138DPo= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= @@ -164,13 +166,11 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU= github.com/AzureAD/microsoft-authentication-library-for-go v0.5.1/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0 h1:hVeq+yCyUi+MsoO/CU95yqCIcdzra5ovzk8Q2BBpV2M= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.0/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak= github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= -github.com/ChannelMeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61 h1:N5Vqww5QISEHsWHOWDEx4PzdIay3Cg0Jp7zItq2ZAro= -github.com/ChannelMeter/iso8601duration v0.0.0-20150204201828-8da3af7a2a61/go.mod h1:GnKXcK+7DYNy/8w2Ex//Uql4IgfaU82Cd5rWKb7ah00= github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/DATA-DOG/go-sqlmock v1.4.1/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -559,6 +559,7 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgrijalva/jwt-go/v4 v4.0.0-preview1/go.mod h1:+hnT3ywWDTAFrW5aE+u2Sa/wT555ZqwoCS+pk3p6ry4= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/digitalocean/godo v1.1.1/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/digitalocean/godo v1.7.5/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= github.com/digitalocean/godo v1.10.0/go.mod h1:h6faOIcZ8lWIwNQ+DN7b3CgX4Kwby5T+nbpNqkUIozU= @@ -629,8 +630,8 @@ github.com/ema/qdisc v1.0.0 h1:EHLG08FVRbWLg8uRICa3xzC9Zm0m7HyMHfXobWFnXYg= github.com/ema/qdisc v1.0.0/go.mod h1:FhIc0fLYi7f+lK5maMsesDqwYojIOh3VfRs8EVd5YJQ= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= -github.com/emicklei/go-restful/v3 v3.10.2 h1:hIovbnmBTLjHXkqEBUz3HGpXZdM7ZrE9fJIZIqlJLqE= -github.com/emicklei/go-restful/v3 v3.10.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/envoyproxy/go-control-plane v0.0.0-20180919002855-2137d9196328/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= @@ -715,9 +716,8 @@ github.com/go-git/go-git-fixtures/v4 v4.2.1/go.mod h1:K8zd3kDUAykwTdDCr+I0per6Y6 github.com/go-git/go-git/v5 v5.4.2 h1:BXyZu9t0VkbiHtqrsvdq39UDhGJTl1h55VW6CSC4aY4= github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti4ihgckDc= github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8= +github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo= github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= -github.com/go-jose/go-jose/v3 v3.0.1 h1:pWmKFVtt+Jl0vBZTIpz/eAKwsm6LkIxDVVbFHKkchhA= -github.com/go-jose/go-jose/v3 v3.0.1/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= @@ -873,6 +873,8 @@ github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe h1:lXe2qZdvpiX5WZkZR4hgp4KJVfY3nMkvmwbVkpv1rVY= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -1001,8 +1003,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.1 h1:SBWmZhjUDRorQxrN0nwzf+AHBxnbFjViHQS4P0yVpmQ= github.com/googleapis/enterprise-certificate-proxy v0.3.1/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -1997,13 +1999,15 @@ github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= -github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= -github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/prometheus/snmp_exporter v0.24.1 h1:AihTbJHurMo8bjtjJde8U+4gMEvpvYvT21Xbd4SzJgY= github.com/prometheus/snmp_exporter v0.24.1/go.mod h1:j6uIGkdR0DXvKn7HJtSkeDj//UY0sWmdd6XhvdBjln0= github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= github.com/prometheus/statsd_exporter v0.22.8 h1:Qo2D9ZzaQG+id9i5NYNGmbf1aa/KxKbB9aKfMS+Yib0= github.com/prometheus/statsd_exporter v0.22.8/go.mod h1:/DzwbTEaFTE0Ojz5PqcSk6+PFHOPWGxdXVr6yC8eFOM= +github.com/prometheus/tsdb v0.10.0 h1:If5rVCMTp6W2SiRAQFlbpJNgVlgMEd+U2GZckwK38ic= +github.com/prometheus/tsdb v0.10.0/go.mod h1:oi49uRhEe9dPUTlS3JRZOwJuVi6tmh10QSgwXEyGCt4= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= @@ -2239,10 +2243,10 @@ github.com/vmware/govmomi v0.32.0/go.mod h1:JA63Pg0SgQcSjk+LuPzjh3rJdcWBo/ZNCIwb github.com/vultr/govultr/v2 v2.17.2 h1:gej/rwr91Puc/tgh+j33p/BLR16UrIPnSr+AIwYWZQs= github.com/vultr/govultr/v2 v2.17.2/go.mod h1:ZFOKGWmgjytfyjeyAdhQlSWwTjh2ig+X49cAp50dzXI= github.com/wavefronthq/wavefront-sdk-go v0.9.2/go.mod h1:hQI6y8M9OtTCtc0xdwh+dCER4osxXdEAeCpacjpDZEU= -github.com/webdevops/azure-metrics-exporter v0.0.0-20230502203721-b2bfd97b5313 h1:FhZihr479Z9UK+yFNLbAucgtKspEZcrJoHZh3XjNMiQ= -github.com/webdevops/azure-metrics-exporter v0.0.0-20230502203721-b2bfd97b5313/go.mod h1:CCKWnozFp+7OxV3pkAFnCRIOtINULwH81JDkr1UPlIY= -github.com/webdevops/go-common v0.0.0-20230612205735-2ee45347be15 h1:3+zCVejFHGmjWyEIbrid1d483SJOvYgLW7q3xEYchjE= -github.com/webdevops/go-common v0.0.0-20230612205735-2ee45347be15/go.mod h1:KUQ7bNZHIHSU4BryRq2E77ob0hrXWZ6CtSbcnqKlUyw= +github.com/webdevops/azure-metrics-exporter v0.0.0-20230717202958-8701afc2b013 h1:4yXSAbV4ImUZYzZf1M+b75/i2nPapEq4J3gs197gKqk= +github.com/webdevops/azure-metrics-exporter v0.0.0-20230717202958-8701afc2b013/go.mod h1:0TRsV1G8hE9GnGY7kHhHg2G5ZGAJLJxMBwHvwRgnuGM= +github.com/webdevops/go-common v0.0.0-20231022162947-a6adfb05a7e9 h1:BMd0HsdcfJW6tYYXaXMpqPcKrJGTkmFtvZ9JV5iXwZ4= +github.com/webdevops/go-common v0.0.0-20231022162947-a6adfb05a7e9/go.mod h1:p2uQLGTFmT2gZqRV8JE8bJU7ln5fmTAe6wOOCVBuew8= github.com/willf/bitset v1.1.11 h1:N7Z7E9UvjW+sGsEl7k/SJrvY2reP1A07MrGuCjIOjRE= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= github.com/willf/bloom v2.0.3+incompatible h1:QDacWdqcAUI1MPOwIQZRy9kOR7yxfyEmxX8Wdm2/JPA= @@ -2951,8 +2955,9 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= +google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -3154,8 +3159,8 @@ k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j k8s.io/api v0.0.0-20190325185214-7544f9db76f6/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/api v0.18.2/go.mod h1:SJCWI7OLzhZSvbY7U8zwNl9UA4o1fizoug34OV/2r78= k8s.io/api v0.21.1/go.mod h1:FstGROTmsSHBarKc8bylzXih8BLNYTiS3TZcsoEDg2s= -k8s.io/api v0.28.2 h1:9mpl5mOb6vXZvqbQmankOfPIGiudghwCoLl1EYfUZbw= -k8s.io/api v0.28.2/go.mod h1:RVnJBsjU8tcMq7C3iaRSGMeaKt2TWEUXcpIt/90fjEg= +k8s.io/api v0.28.3 h1:Gj1HtbSdB4P08C8rs9AR94MfSGpRhJgsS+GF9V26xMM= +k8s.io/api v0.28.3/go.mod h1:MRCV/jr1dW87/qJnZ57U5Pak65LGmQVkKTzf3AtKFHc= k8s.io/apiextensions-apiserver v0.28.0 h1:CszgmBL8CizEnj4sj7/PtLGey6Na3YgWyGCPONv7E9E= k8s.io/apiextensions-apiserver v0.28.0/go.mod h1:uRdYiwIuu0SyqJKriKmqEN2jThIJPhVmOWETm8ud1VE= k8s.io/apimachinery v0.0.0-20180821005732-488889b0007f/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= @@ -3163,12 +3168,12 @@ k8s.io/apimachinery v0.0.0-20190223001710-c182ff3b9841/go.mod h1:ccL7Eh7zubPUSh9 k8s.io/apimachinery v0.17.1/go.mod h1:b9qmWdKlLuU9EBh+06BtLcSf/Mu89rWL33naRxs1uZg= k8s.io/apimachinery v0.18.2/go.mod h1:9SnR/e11v5IbyPCGbvJViimtJ0SwHG4nfZFjU77ftcA= k8s.io/apimachinery v0.21.1/go.mod h1:jbreFvJo3ov9rj7eWT7+sYiRx+qZuCYXwWT1bcDswPY= -k8s.io/apimachinery v0.28.2 h1:KCOJLrc6gu+wV1BYgwik4AF4vXOlVJPdiqn0yAWWwXQ= -k8s.io/apimachinery v0.28.2/go.mod h1:RdzF87y/ngqk9H4z3EL2Rppv5jj95vGS/HaFXrLDApU= +k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A= +k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8= k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU= k8s.io/client-go v0.21.1/go.mod h1:/kEw4RgW+3xnBGzvp9IWxKSNA+lXn3A7AuH3gdOAzLs= -k8s.io/client-go v0.28.2 h1:DNoYI1vGq0slMBN/SWKMZMw0Rq+0EQW6/AK4v9+3VeY= -k8s.io/client-go v0.28.2/go.mod h1:sMkApowspLuc7omj1FOSUxSoqjr+d5Q0Yc0LOFnYFJY= +k8s.io/client-go v0.28.3 h1:2OqNb72ZuTZPKCl+4gTKvqao0AMOl9f3o2ijbAj3LI4= +k8s.io/client-go v0.28.3/go.mod h1:LTykbBp9gsA7SwqirlCXBWtK0guzfhpoW4qSm7i9dxo= k8s.io/code-generator v0.21.1/go.mod h1:hUlps5+9QaTrKx+jiM4rmq7YmH8wPOIko64uZCHDh6Q= k8s.io/component-base v0.28.1 h1:LA4AujMlK2mr0tZbQDZkjWbdhTV5bRyEyAFe0TJxlWg= k8s.io/component-base v0.28.1/go.mod h1:jI11OyhbX21Qtbav7JkhehyBsIRfnO8oEgoAR12ArIU= @@ -3178,12 +3183,12 @@ k8s.io/gengo v0.0.0-20201214224949-b6c5ce23f027/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAE k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a/go.mod h1:1TqjTSzOxsLGIKfj0lK8EeCP7K1iUG65v09OM0/WG5E= k8s.io/kube-openapi v0.0.0-20200121204235-bf4fb3bd569c/go.mod h1:GRQhZsXIAJ1xR0C9bd8UpWHZ5plfAS9fzPjJuQ6JL3E= k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7/go.mod h1:wXW5VT87nVfh/iLV8FpR2uDvrFyomxbtb1KivDbvPTE= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ= -k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew= k8s.io/utils v0.0.0-20201110183641-67b214c5f920/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -k8s.io/utils v0.0.0-20230711102312-30195339c3c7 h1:ZgnF1KZsYxWIifwSNZFZgNtWE89WI5yiP5WwlfDoIyc= -k8s.io/utils v0.0.0-20230711102312-30195339c3c7/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= modernc.org/httpfs v1.0.0/go.mod h1:BSkfoMUcahSijQD5J/Vu4UMOxzmEf5SNRwyXC4PJBEw= modernc.org/libc v1.3.1/go.mod h1:f8sp9GAfEyGYh3lsRIKtBh/XwACdFvGznxm6GJmQvXk= modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= diff --git a/pkg/integrations/azure_exporter/azure_exporter.go b/pkg/integrations/azure_exporter/azure_exporter.go index 864485732d7d..8f2996a65e04 100644 --- a/pkg/integrations/azure_exporter/azure_exporter.go +++ b/pkg/integrations/azure_exporter/azure_exporter.go @@ -24,7 +24,7 @@ type Exporter struct { } func (e Exporter) MetricsHandler() (http.Handler, error) { - //Safe to re-use as it doesn't connect to anything directly + // Safe to re-use as it doesn't connect to anything directly client, err := armclient.NewArmClientWithCloudName(e.cfg.AzureCloudEnvironment, e.logger) if err != nil { return nil, fmt.Errorf("failed to create azure client, %v", err) @@ -35,7 +35,13 @@ func (e Exporter) MetricsHandler() (http.Handler, error) { ctx := context.Background() params := req.URL.Query() - mergedConfig := MergeConfigWithQueryParams(e.cfg, params) + mergedConfig, err := MergeConfigWithQueryParams(e.cfg, params) + if err != nil { + err = fmt.Errorf("failed to merge config with query parameters, %v", err) + e.logger.Error(err) + http.Error(resp, err.Error(), http.StatusBadRequest) + return + } if err := mergedConfig.Validate(); err != nil { err = fmt.Errorf("config to be used for scraping was invalid, %v", err) @@ -71,15 +77,23 @@ func (e Exporter) MetricsHandler() (http.Handler, error) { prober.SetPrometheusRegistry(reg) prober.SetAzureResourceTagManager(tagManager) - err = prober.ServiceDiscovery.FindResourceGraph(ctx, settings.Subscriptions, settings.ResourceType, settings.Filter) - if err != nil { - e.logger.Error(fmt.Errorf("service discovery failed, %v", err)) - http.Error(resp, "Failed to discovery azure resources", http.StatusInternalServerError) - return + // When regions has values then the request is for all resources in the subscription. + // "RunOnSubscriptionScope" uses a different API, https://github.com/Azure/azure-rest-api-specs/blob/main/specification/monitor/resource-manager/Microsoft.Insights/stable/2021-05-01/metrics_API.json#L40, + // which can get metric data for all resources in a single API call reducing overhead/likelihood of being rate limited. + // Limiting to specific resources requires 1 API call per resource to get metrics which can easily lead to rate limiting + if len(settings.Regions) > 1 { + prober.RunOnSubscriptionScope() + } else { + err = prober.ServiceDiscovery.FindResourceGraph(ctx, settings.Subscriptions, settings.ResourceType, settings.Filter) + if err != nil { + e.logger.Error(fmt.Errorf("service discovery failed, %v", err)) + http.Error(resp, "Failed to discovery azure resources", http.StatusInternalServerError) + return + } + + prober.Run() } - prober.Run() - promhttp.HandlerFor(reg, promhttp.HandlerOpts{}).ServeHTTP(resp, req) }) return h, nil diff --git a/pkg/integrations/azure_exporter/config.go b/pkg/integrations/azure_exporter/config.go index 45862b587bf2..17893dc435a0 100644 --- a/pkg/integrations/azure_exporter/config.go +++ b/pkg/integrations/azure_exporter/config.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "net/url" + "strconv" "strings" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" @@ -33,11 +34,16 @@ var DefaultConfig = Config{ MetricHelpTemplate: "Azure metric {metric} for {type} with aggregation {aggregation} as {unit}", IncludedResourceTags: []string{"owner"}, AzureCloudEnvironment: "azurecloud", + // Dimensions do not always apply to all metrics for a service, which requires you to configure multiple exporters + // to fully monitor a service which is tedious. Turning off validation eliminates this complexity. The underlying + // sdk will only give back the dimensions which are valid for particular metrics. + ValidateDimensions: false, } type Config struct { Subscriptions []string `yaml:"subscriptions"` // Required ResourceGraphQueryFilter string `yaml:"resource_graph_query_filter"` // Optional + Regions []string `yaml:"regions"` // Optional // Valid values can be derived from https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/metrics-supported // Required: Root level names ex. Microsoft.DataShare/accounts @@ -68,6 +74,7 @@ type Config struct { MetricNameTemplate string `yaml:"metric_name_template"` MetricHelpTemplate string `yaml:"metric_help_template"` + ValidateDimensions bool `yaml:"validate_dimensions"` AzureCloudEnvironment string `yaml:"azure_cloud_environment"` } @@ -120,6 +127,10 @@ func (c *Config) Validate() error { configErrors = append(configErrors, "metrics cannot be empty") } + if len(c.Regions) > 0 && c.ResourceGraphQueryFilter != "" { + configErrors = append(configErrors, "regions and resource_graph_query_filter cannot be used together. If you want to target specific resources add a region filter to the resource_graph_query_filter. Otherwise, remove your resource_graph_query_filter to get metrics without further filtering.") + } + validAggregations := []string{"minimum", "maximum", "average", "total", "count"} for _, aggregation := range c.MetricAggregations { @@ -153,14 +164,16 @@ func (c *Config) Name() string { func (c *Config) ToScrapeSettings() (*metrics.RequestMetricSettings, error) { settings := metrics.RequestMetricSettings{ - Subscriptions: c.Subscriptions, - Metrics: c.Metrics, - ResourceType: c.ResourceType, - Aggregations: c.MetricAggregations, - Filter: c.ResourceGraphQueryFilter, - MetricNamespace: c.MetricNamespace, - MetricTemplate: c.MetricNameTemplate, - HelpTemplate: c.MetricHelpTemplate, + Subscriptions: c.Subscriptions, + Metrics: c.Metrics, + ResourceType: c.ResourceType, + Aggregations: c.MetricAggregations, + Filter: c.ResourceGraphQueryFilter, + MetricNamespace: c.MetricNamespace, + MetricTemplate: c.MetricNameTemplate, + HelpTemplate: c.MetricHelpTemplate, + ValidateDimensions: c.ValidateDimensions, + Regions: c.Regions, // Interval controls data aggregation timeframe ie 1 minute or 5 minutes aggregations // Timespan controls query start and end time @@ -205,7 +218,7 @@ func (c *Config) ToScrapeSettings() (*metrics.RequestMetricSettings, error) { // MergeConfigWithQueryParams will map values from params which where the key // matches a yaml tag of the Config struct -func MergeConfigWithQueryParams(cfg Config, params url.Values) Config { +func MergeConfigWithQueryParams(cfg Config, params url.Values) (Config, error) { if subscriptions, exists := params["subscriptions"]; exists { cfg.Subscriptions = subscriptions } @@ -256,7 +269,20 @@ func MergeConfigWithQueryParams(cfg Config, params url.Values) Config { cfg.MetricHelpTemplate = helpTemplate } - return cfg + if regions, exists := params["regions"]; exists { + cfg.Regions = regions + } + + validateDimensions := params.Get("validate_dimensions") + if len(validateDimensions) != 0 { + v, err := strconv.ParseBool(validateDimensions) + if err != nil { + return Config{}, fmt.Errorf("invalid boolean value %s for validate_dimensions", validateDimensions) + } + cfg.ValidateDimensions = v + } + + return cfg, nil } // getHash calculates the MD5 hash of the yaml representation of the config diff --git a/pkg/integrations/azure_exporter/config_test.go b/pkg/integrations/azure_exporter/config_test.go index afae4b2746b2..4690184a59c2 100644 --- a/pkg/integrations/azure_exporter/config_test.go +++ b/pkg/integrations/azure_exporter/config_test.go @@ -38,7 +38,7 @@ func TestConfig_ToScrapeSettings(t *testing.T) { MetricTemplate: "name_template_me", HelpTemplate: "help_template_me", - //Should not be set + // Should not be set Name: "", MetricTop: nil, MetricFilter: "", @@ -177,6 +177,14 @@ func TestConfig_Validate(t *testing.T) { return config }, }, + { + name: "includes Regions and ResourceGraphQueryFilter", + toInvalidConfig: func(config azure_exporter.Config) azure_exporter.Config { + config.ResourceGraphQueryFilter = "filter the resources" + config.Regions = []string{"uswest", "useast"} + return config + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -193,7 +201,7 @@ func TestMergeConfigWithQueryParams_MapsAllExpectedFieldsByYamlNameFromConfig(t var mappableFields []reflect.StructField for i := 0; i < thing.NumField(); i++ { field := thing.Field(i) - //Not available to be mapped via query param + // Not available to be mapped via query param if field.Name == "AzureCloudEnvironment" { continue } @@ -216,6 +224,9 @@ func TestMergeConfigWithQueryParams_MapsAllExpectedFieldsByYamlNameFromConfig(t value := []string{"fake string 1", "fake string 2"} fieldValue = value urlParams[yamlFieldName] = value + case "bool": + urlParams[yamlFieldName] = []string{"false"} + fieldValue = false default: t.Fatalf("Attempting to map %s, discovered unexpected type %s", mappableField.Name, mappableField.Type.String()) } @@ -223,7 +234,8 @@ func TestMergeConfigWithQueryParams_MapsAllExpectedFieldsByYamlNameFromConfig(t expectedConfig := &azure_exporter.Config{} reflect.ValueOf(expectedConfig).Elem().FieldByName(mappableField.Name).Set(reflect.ValueOf(fieldValue)) - actualConfig := azure_exporter.MergeConfigWithQueryParams(azure_exporter.Config{}, urlParams) + actualConfig, err := azure_exporter.MergeConfigWithQueryParams(azure_exporter.Config{}, urlParams) + require.NoError(t, err) require.Equal(t, *expectedConfig, actualConfig) }) } diff --git a/pkg/operator/config/config_test.go b/pkg/operator/config/config_test.go index 532a8d546aaa..d9ad7b16a02e 100644 --- a/pkg/operator/config/config_test.go +++ b/pkg/operator/config/config_test.go @@ -4,16 +4,17 @@ import ( "fmt" "testing" - "github.com/grafana/agent/pkg/operator/assets" - "github.com/grafana/agent/pkg/util" - "github.com/grafana/agent/pkg/util/subset" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" k8s_yaml "sigs.k8s.io/yaml" + "github.com/grafana/agent/pkg/operator/assets" + "github.com/grafana/agent/pkg/util" + "github.com/grafana/agent/pkg/util/subset" + gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" ) @@ -231,7 +232,7 @@ func TestAdditionalScrapeConfigsMetrics(t *testing.T) { Name: "agent", }, Spec: gragent.GrafanaAgentSpec{ - Image: pointer.String("grafana/agent:latest"), + Image: ptr.To("grafana/agent:latest"), ServiceAccountName: "agent", Metrics: gragent.MetricsSubsystemSpec{ InstanceSelector: &meta_v1.LabelSelector{ diff --git a/pkg/operator/config/metrics_templates_test.go b/pkg/operator/config/metrics_templates_test.go index e0182ea6249c..1b7cb619bc9d 100644 --- a/pkg/operator/config/metrics_templates_test.go +++ b/pkg/operator/config/metrics_templates_test.go @@ -6,16 +6,17 @@ import ( "strings" "testing" - jsonnet "github.com/google/go-jsonnet" - gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" - "github.com/grafana/agent/pkg/operator/assets" - "github.com/grafana/agent/pkg/util" + "github.com/google/go-jsonnet" prom_v1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" + + gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" + "github.com/grafana/agent/pkg/operator/assets" + "github.com/grafana/agent/pkg/util" ) func TestExternalLabels(t *testing.T) { @@ -89,8 +90,8 @@ func TestExternalLabels(t *testing.T) { }, Spec: gragent.GrafanaAgentSpec{ Metrics: gragent.MetricsSubsystemSpec{ - MetricsExternalLabelName: pointer.String("deployment"), - ReplicaExternalLabelName: pointer.String("replica"), + MetricsExternalLabelName: ptr.To("deployment"), + ReplicaExternalLabelName: ptr.To("replica"), ExternalLabels: map[string]string{"foo": "bar"}, }, }, diff --git a/pkg/operator/reconciler_metrics.go b/pkg/operator/reconciler_metrics.go index 9873708479bb..eec1ffa072fb 100644 --- a/pkg/operator/reconciler_metrics.go +++ b/pkg/operator/reconciler_metrics.go @@ -11,16 +11,17 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/google/go-jsonnet" - gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" - "github.com/grafana/agent/pkg/operator/clientutil" - "github.com/grafana/agent/pkg/operator/config" apps_v1 "k8s.io/api/apps/v1" core_v1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" + + gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" + "github.com/grafana/agent/pkg/operator/clientutil" + "github.com/grafana/agent/pkg/operator/config" ) // createMetricsConfigurationSecret creates the Grafana Agent metrics configuration and stores @@ -99,7 +100,7 @@ func (r *reconciler) createTelemetryConfigurationSecret( Labels: r.config.Labels.Merge(managedByOperatorLabels), OwnerReferences: []v1.OwnerReference{{ APIVersion: d.Agent.APIVersion, - BlockOwnerDeletion: pointer.Bool(true), + BlockOwnerDeletion: ptr.To(true), Kind: d.Agent.Kind, Name: d.Agent.Name, UID: d.Agent.UID, diff --git a/pkg/operator/resources_metrics.go b/pkg/operator/resources_metrics.go index 0081f4490af0..ee6e0cdbbbd2 100644 --- a/pkg/operator/resources_metrics.go +++ b/pkg/operator/resources_metrics.go @@ -5,15 +5,16 @@ import ( "fmt" "strings" - gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" prom_operator "github.com/prometheus-operator/prometheus-operator/pkg/operator" apps_v1 "k8s.io/api/apps/v1" core_v1 "k8s.io/api/core/v1" k8s_errors "k8s.io/apimachinery/pkg/api/errors" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" + + gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" ) const ( @@ -77,8 +78,8 @@ func generateMetricsStatefulSetService(cfg *Config, d gragent.Deployment) *core_ APIVersion: d.Agent.APIVersion, Kind: d.Agent.Kind, Name: d.Agent.Name, - BlockOwnerDeletion: pointer.Bool(true), - Controller: pointer.Bool(true), + BlockOwnerDeletion: ptr.To(true), + Controller: ptr.To(true), UID: d.Agent.UID, }}, Labels: cfg.Labels.Merge(map[string]string{ @@ -230,8 +231,8 @@ func metadataFromPodTemplate(name string, d gragent.Deployment, tmpl core_v1.Pod OwnerReferences: []meta_v1.OwnerReference{{ APIVersion: d.Agent.APIVersion, Kind: d.Agent.Kind, - BlockOwnerDeletion: pointer.Bool(true), - Controller: pointer.Bool(true), + BlockOwnerDeletion: ptr.To(true), + Controller: ptr.To(true), Name: d.Agent.Name, UID: d.Agent.UID, }}, diff --git a/pkg/operator/resources_pod_template.go b/pkg/operator/resources_pod_template.go index 5e97851cd8ce..c4b82cc0f279 100644 --- a/pkg/operator/resources_pod_template.go +++ b/pkg/operator/resources_pod_template.go @@ -4,13 +4,14 @@ import ( "fmt" "path" - "github.com/grafana/agent/pkg/build" - gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" - "github.com/grafana/agent/pkg/operator/clientutil" core_v1 "k8s.io/api/core/v1" meta_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" + + "github.com/grafana/agent/pkg/build" + gragent "github.com/grafana/agent/pkg/operator/apis/monitoring/v1alpha1" + "github.com/grafana/agent/pkg/operator/clientutil" ) type podTemplateOptions struct { @@ -258,7 +259,7 @@ func generatePodTemplate( }, Resources: d.Agent.Spec.Resources, SecurityContext: &core_v1.SecurityContext{ - Privileged: pointer.Bool(opts.Privileged), + Privileged: ptr.To(opts.Privileged), }, TerminationMessagePolicy: core_v1.TerminationMessageFallbackToLogsOnError, }, @@ -288,7 +289,7 @@ func generatePodTemplate( NodeSelector: d.Agent.Spec.NodeSelector, PriorityClassName: d.Agent.Spec.PriorityClassName, RuntimeClassName: d.Agent.Spec.RuntimeClassName, - TerminationGracePeriodSeconds: pointer.Int64(4800), + TerminationGracePeriodSeconds: ptr.To(int64(4800)), Volumes: volumes, Tolerations: d.Agent.Spec.Tolerations, Affinity: d.Agent.Spec.Affinity, diff --git a/pkg/util/testappender/internal/dtobuilder/dtobuilder.go b/pkg/util/testappender/internal/dtobuilder/dtobuilder.go index 3aa15bb9e5a7..7af96e485d85 100644 --- a/pkg/util/testappender/internal/dtobuilder/dtobuilder.go +++ b/pkg/util/testappender/internal/dtobuilder/dtobuilder.go @@ -15,7 +15,7 @@ import ( "github.com/prometheus/prometheus/model/metadata" "github.com/prometheus/prometheus/model/textparse" "google.golang.org/protobuf/types/known/timestamppb" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) // Sample represents an individually written sample to a storage.Appender. @@ -118,11 +118,11 @@ func (b *builder) buildFamiliesFromMetadata() { for familyName, m := range b.Metadata { mt := textParseToMetricType(m.Type) mf := &dto.MetricFamily{ - Name: pointer.String(familyName), + Name: ptr.To(familyName), Type: &mt, } if m.Help != "" { - mf.Help = pointer.String(m.Help) + mf.Help = ptr.To(m.Help) } b.families = append(b.families, mf) @@ -225,18 +225,18 @@ func (b *builder) buildMetricsFromSamples() { // Retrieve the *dto.Metric based on labels. m := getOrCreateMetric(mf, sample.Labels) if sample.PrintTimestamp { - m.TimestampMs = pointer.Int64(sample.Timestamp) + m.TimestampMs = ptr.To(sample.Timestamp) } switch familyType(mf) { case dto.MetricType_COUNTER: m.Counter = &dto.Counter{ - Value: pointer.Float64(sample.Value), + Value: ptr.To(sample.Value), } case dto.MetricType_GAUGE: m.Gauge = &dto.Gauge{ - Value: pointer.Float64(sample.Value), + Value: ptr.To(sample.Value), } case dto.MetricType_SUMMARY: @@ -249,7 +249,7 @@ func (b *builder) buildMetricsFromSamples() { val := uint64(sample.Value) m.Summary.SampleCount = &val case metricName == mf.GetName()+"_sum": - m.Summary.SampleSum = pointer.Float64(sample.Value) + m.Summary.SampleSum = ptr.To(sample.Value) case metricName == mf.GetName(): quantile, err := strconv.ParseFloat(sample.Labels.Get(model.QuantileLabel), 64) if err != nil { @@ -258,13 +258,13 @@ func (b *builder) buildMetricsFromSamples() { m.Summary.Quantile = append(m.Summary.Quantile, &dto.Quantile{ Quantile: &quantile, - Value: pointer.Float64(sample.Value), + Value: ptr.To(sample.Value), }) } case dto.MetricType_UNTYPED: m.Untyped = &dto.Untyped{ - Value: pointer.Float64(sample.Value), + Value: ptr.To(sample.Value), } case dto.MetricType_HISTOGRAM: @@ -277,7 +277,7 @@ func (b *builder) buildMetricsFromSamples() { val := uint64(sample.Value) m.Histogram.SampleCount = &val case metricName == mf.GetName()+"_sum": - m.Histogram.SampleSum = pointer.Float64(sample.Value) + m.Histogram.SampleSum = ptr.To(sample.Value) case metricName == mf.GetName()+"_bucket": boundary, err := strconv.ParseFloat(sample.Labels.Get(model.BucketLabel), 64) if err != nil { @@ -345,8 +345,8 @@ func toLabelPairs(mt dto.MetricType, ls labels.Labels) []*dto.LabelPair { } res = append(res, &dto.LabelPair{ - Name: pointer.String(l.Name), - Value: pointer.String(l.Value), + Name: ptr.To(l.Name), + Value: ptr.To(l.Value), }) } diff --git a/tools/smoke/internal/tasks.go b/tools/smoke/internal/tasks.go index 3b887d577f77..a2243f512a4a 100644 --- a/tools/smoke/internal/tasks.go +++ b/tools/smoke/internal/tasks.go @@ -9,7 +9,7 @@ import ( "github.com/go-kit/log/level" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) // The Task interface represents some unit of work performed concurrently. @@ -32,7 +32,7 @@ type deletePodTask struct { func (t *deletePodTask) Run(ctx context.Context) error { level.Debug(t.logger).Log("msg", "deleting pod") if err := t.clientset.CoreV1().Pods(t.namespace).Delete(ctx, t.pod, metav1.DeleteOptions{ - GracePeriodSeconds: pointer.Int64(0), + GracePeriodSeconds: ptr.To(int64(0)), }); err != nil { level.Error(t.logger).Log("msg", "failed to delete pod", "err", err) } @@ -91,7 +91,7 @@ func (t *deletePodBySelectorTask) Run(ctx context.Context) error { pod := list.Items[i].Name level.Debug(t.logger).Log("msg", "deleting pod", "pod", pod) if err := t.clientset.CoreV1().Pods(t.namespace).Delete(ctx, pod, metav1.DeleteOptions{ - GracePeriodSeconds: pointer.Int64(0), + GracePeriodSeconds: ptr.To(int64(0)), }); err != nil { level.Error(t.logger).Log("msg", "failed to delete pod", "pod", pod, "err", err) }