Skip to content

Commit

Permalink
apply suggestions from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Bacher <[email protected]>
  • Loading branch information
bacherfl committed Apr 16, 2024
1 parent fd74954 commit 7e567f8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
20 changes: 18 additions & 2 deletions docs/gitbook/usage/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,24 @@ metadata:
spec:
provider:
type: keptn
query: |
keptnmetric/my-namespace/response-time
query: keptnmetric/my-namespace/response-time
```
This will reference the `KeptnMetric` with the name `response-time` in
the namespace `my-namespace`, which could look like the following:

```yaml
apiVersion: metrics.keptn.sh/v1beta1
kind: KeptnMetric
metadata:
name: response-time
namespace: my-namespace
spec:
fetchIntervalSeconds: 10
provider:
name: my-prometheus-keptn-provider
query: histogram_quantile(0.8, sum by(le) (rate(http_server_request_latency_seconds_bucket{status_code='200',
job='simple-go-backend'}[5m[])))
```

The `query` contains the following components, which are divided by `/` characters:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ require (
github.com/davecgh/go-spew v1.1.1
github.com/go-logr/zapr v1.3.0
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
github.com/googleapis/gax-go/v2 v2.12.3
github.com/hashicorp/go-retryablehttp v0.7.5
github.com/influxdata/influxdb-client-go/v2 v2.13.0
github.com/prometheus/client_golang v1.19.0
github.com/stretchr/testify v1.9.0
go.uber.org/zap v1.27.0
golang.org/x/sync v0.6.0
google.golang.org/api v0.171.0
google.golang.org/genproto v0.0.0-20240325203815-454cdb8f5daa
google.golang.org/grpc v1.62.1
Expand Down Expand Up @@ -46,7 +48,6 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -76,7 +77,6 @@ require (
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package controller

import (
"fmt"
"k8s.io/client-go/rest"
"sync"
"time"

"k8s.io/client-go/rest"

"github.com/google/go-cmp/cmp"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"
Expand Down
7 changes: 4 additions & 3 deletions pkg/metrics/providers/keptn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import (
"context"
"errors"
"fmt"
"strconv"
"strings"
"time"

"github.com/google/uuid"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/rest"
"strconv"
"strings"
"time"
)

// api version for the Keptn Metric CRDs
Expand Down
5 changes: 3 additions & 2 deletions pkg/metrics/providers/keptn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"context"
"errors"
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -12,8 +15,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic/fake"
"k8s.io/client-go/rest"
"testing"
"time"
)

func TestNewKeptnProvider(t *testing.T) {
Expand Down

0 comments on commit 7e567f8

Please sign in to comment.