-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: PC-13027 PC-13029 Add Azure Monitor managed service for Prometh… (
#437) ## Motivation Support new integration with Azure Monitor managed service for Prometheus ## Summary New fields in Agent spec: ``` spec: azurePrometheus: url: "" tenantId: "" ``` - `azurePrometheus` - name of the new integration - `url` - is the `Endpoint - query URL` in Azure Prometheus ([How to find the Prometheus URL?](https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/prometheus-api-promql#query-endpoint)) - `tenentId` - Azure [tenent ID](https://learn.microsoft.com/en-us/azure/azure-portal/get-subscription-tenant-id#find-your-azure-ad-tenant) New fields in Metric Spec, example: ``` countMetrics: incremental: false good: azurePrometheus: promql: "" total: azurePrometheus: promql: "" ``` - `azurePrometheus` - name of the new integration - `promql` - a Prometheus query in the [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/) (Prometheus Query Language) that allows the user to select and aggregate time-series data in real-tim ## Release Notes Added Azure Monitor managed service for Prometheus Agent, and Metric Spec extending both `v1alpha.Agent.Spec` and `v1alpha.SLO.MetricSpec`.
- Loading branch information
Showing
11 changed files
with
207 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
package slo | ||
|
||
import "github.com/nobl9/nobl9-go/internal/validation" | ||
|
||
// AzurePrometheusMetric represents metric from Azure Monitor managed service for Prometheus | ||
type AzurePrometheusMetric struct { | ||
PromQL string `json:"promql"` | ||
} | ||
|
||
var azurePrometheusValidation = validation.New[AzurePrometheusMetric]( | ||
validation.For(func(p AzurePrometheusMetric) string { return p.PromQL }). | ||
WithName("promql"). | ||
Required(). | ||
Rules(validation.StringNotEmpty()), | ||
) |
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,35 @@ | ||
package slo | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/nobl9/nobl9-go/internal/testutils" | ||
"github.com/nobl9/nobl9-go/internal/validation" | ||
"github.com/nobl9/nobl9-go/manifest/v1alpha" | ||
) | ||
|
||
func TestAzurePrometheus(t *testing.T) { | ||
t.Run("passes", func(t *testing.T) { | ||
slo := validRawMetricSLO(v1alpha.AzurePrometheus) | ||
err := validate(slo) | ||
testutils.AssertNoError(t, slo, err) | ||
}) | ||
t.Run("required", func(t *testing.T) { | ||
slo := validRawMetricSLO(v1alpha.AzurePrometheus) | ||
slo.Spec.Objectives[0].RawMetric.MetricQuery.AzurePrometheus = &AzurePrometheusMetric{} | ||
err := validate(slo) | ||
testutils.AssertContainsErrors(t, slo, err, 1, testutils.ExpectedError{ | ||
Prop: "spec.objectives[0].rawMetric.query.azurePrometheus.promql", | ||
Code: validation.ErrorCodeRequired, | ||
}) | ||
}) | ||
t.Run("empty", func(t *testing.T) { | ||
slo := validRawMetricSLO(v1alpha.AzurePrometheus) | ||
slo.Spec.Objectives[0].RawMetric.MetricQuery.AzurePrometheus.PromQL = "" | ||
err := validate(slo) | ||
testutils.AssertContainsErrors(t, slo, err, 1, testutils.ExpectedError{ | ||
Prop: "spec.objectives[0].rawMetric.query.azurePrometheus.promql", | ||
Code: validation.ErrorCodeRequired, | ||
}) | ||
}) | ||
} |
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