Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
build(deps): Update dependencies (#302)
Browse files Browse the repository at this point in the history
Signed-off-by: Raphael Ludwig <[email protected]>
  • Loading branch information
Raffy23 authored May 11, 2022
1 parent 24bf05c commit 96cf984
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 356 deletions.
2 changes: 2 additions & 0 deletions .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: 'Unit Tests'
description: 'Run unit tests using go'
inputs:
GO_VERSION:
description: The GO version that should be used for compilation / execution of the unit tests
required: false
default: "1.17"
env:
GO111MODULE: "on"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defaults:
jobs:
prepare_ci_run:
name: Prepare CI Run
uses: keptn/gh-automation/.github/workflows/[email protected].2
uses: keptn/gh-automation/.github/workflows/[email protected].3

############################################################################
# Unit tests #
Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Docker Build
id: docker_build
uses: keptn/gh-automation/.github/actions/[email protected].2
uses: keptn/gh-automation/.github/actions/[email protected].3
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
pre-release:
needs: test
name: Pre-Release
uses: keptn/gh-automation/.github/workflows/[email protected].2
uses: keptn/gh-automation/.github/workflows/[email protected].3

docker_build:
needs: [pre-release]
Expand All @@ -32,7 +32,7 @@ jobs:
env-file: .ci_env

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected].2
uses: keptn/gh-automation/.github/actions/[email protected].3
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
release:
needs: test
name: Release
uses: keptn/gh-automation/.github/workflows/[email protected].2
uses: keptn/gh-automation/.github/workflows/[email protected].3

docker_build:
needs: [release]
Expand All @@ -32,7 +32,7 @@ jobs:
env-file: .ci_env

- name: Docker Build
uses: keptn/gh-automation/.github/actions/[email protected].2
uses: keptn/gh-automation/.github/actions/[email protected].3
with:
TAGS: |
${{ env.DOCKER_ORGANIZATION }}/${{ env.IMAGE }}:${{ env.VERSION }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-semantic-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- synchronize
jobs:
validate:
uses: keptn/gh-automation/.github/workflows/[email protected].2
uses: keptn/gh-automation/.github/workflows/[email protected].3
with:
# Configure which scopes are allowed.
scopes: |
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Prometheus is then available on [localhost:8080/targets](http://localhost:8080/t

Please replace the placeholders in the commands below. Examples are provided.

* `<VERSION>`: prometheus-service version, e.g., `0.7.1`
* `<VERSION>`: prometheus-service version, e.g., `0.8.0`
* `<PROMETHEUS_NS>`: If prometheus is installed in the same Kubernetes cluster, the namespace needs to be provided, e.g., `monitoring`
* `<PROMETHEUS_ENDPOINT>`: Endpoint for prometheus (primarily used for fetching metrics), e.g., `http://prometheus-server.monitoring.svc.cluster.local:80`
* `<ALERT_MANAGER_NS>`: if prometheus alert manager is installed in the same Kubernetes cluster, the namespace needs to be provided, e.g., `monitoring`
Expand Down Expand Up @@ -185,7 +185,7 @@ Users can override the predefined queries, as well as add custom queries by crea
response_time_p95: histogram_quantile(0.95, sum by(le) (rate(http_response_time_milliseconds_bucket{handler="ItemsController.addToCart",job="$SERVICE-$PROJECT-$STAGE-canary"}[$DURATION_SECONDS])))
```

* To store this configuration, you need to add this file to a Keptn's configuration store. This is done by using the Keptn CLI with the [keptn add-resource](https://keptn.sh/docs/0.8.x/reference/cli/commands/keptn_add-resource/) command (see [SLI Provider](https://keptn.sh/docs/0.8.x/quality_gates/sli-provider/) for more information).
* To store this configuration, you need to add this file to a Keptn's configuration store. This is done by using the Keptn CLI with the [keptn add-resource](https://keptn.sh/docs/0.14.x/reference/cli/commands/keptn_add-resource/) command (see [SLI Provider](https://keptn.sh/docs/0.14.x/quality_gates/sli-provider/) for more information).

---

Expand Down
7 changes: 5 additions & 2 deletions eventhandling/alertEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const remediationTaskName = "remediation"
type alertManagerEvent struct {
Receiver string `json:"receiver"`
Status string `json:"status"`
Alerts []alert `json:"alerts""`
Alerts []alert `json:"alerts"`
}

// alert coming from prometheus
Expand Down Expand Up @@ -113,8 +113,11 @@ func createAndSendCE(problemData keptncommons.ProblemEventData, shkeptncontext s
event.SetType(eventType)
event.SetSource(source.String())
event.SetDataContentType(cloudevents.ApplicationJSON)
event.SetData(cloudevents.ApplicationJSON, problemData)
event.SetExtension("shkeptncontext", shkeptncontext)
err := event.SetData(cloudevents.ApplicationJSON, problemData)
if err != nil {
return fmt.Errorf("unable to set cloud event data: %w", err)
}

keptnHandler, err := keptnv2.NewKeptn(&event, keptn.KeptnOpts{})
if err != nil {
Expand Down
28 changes: 19 additions & 9 deletions eventhandling/configureEvent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import (
prometheus_model "github.com/prometheus/common/model"
)

const Throughput = "throughput"
const ErrorRate = "error_rate"
const ResponseTimeP50 = "response_time_p50"
const ResponseTimeP90 = "response_time_p90"
const ResponseTimeP95 = "response_time_p95"
const metricsScrapePathEnvName = "METRICS_SCRAPE_PATH"

// ConfigureMonitoringEventHandler is responsible for processing configure monitoring events
Expand Down Expand Up @@ -188,7 +183,10 @@ func (eh ConfigureMonitoringEventHandler) updatePrometheusConfigMap(eventData ke
var alertingRulesConfig alertingRules
if cmPrometheus.Data["prometheus.rules"] != "" {
// take existing alerting rule
yaml.Unmarshal([]byte(cmPrometheus.Data["prometheus.rules"]), &alertingRulesConfig)
err := yaml.Unmarshal([]byte(cmPrometheus.Data["prometheus.rules"]), &alertingRulesConfig)
if err != nil {
return fmt.Errorf("unable to parse altering rules configuration: %w", err)
}
} else {
// create new empty alerting rule
alertingRulesConfig = alertingRules{}
Expand Down Expand Up @@ -243,8 +241,14 @@ func (eh ConfigureMonitoringEventHandler) createPrometheusAlertsIfSLOsAndRemedia
}

const remediationFileDefaultName = "remediation.yaml"
_, err = eh.keptnHandler.ResourceHandler.GetServiceResource(eventData.Project, stage.Name, eventData.Service,
remediationFileDefaultName)

resourceScope := configutils.NewResourceScope()
resourceScope.Project(eventData.Project)
resourceScope.Service(eventData.Service)
resourceScope.Stage(stage.Name)
resourceScope.Resource(remediationFileDefaultName)

_, err = eh.keptnHandler.ResourceHandler.GetResource(*resourceScope)

if errors.Is(err, configutils.ResourceNotFoundError) {
eh.logger.Infof("No remediation defined for project %s stage %s, skipping setup of prometheus alerts",
Expand Down Expand Up @@ -425,7 +429,13 @@ func getConfigurationServiceURL() string {
func retrieveSLOs(eventData keptnevents.ConfigureMonitoringEventData, stage string, logger keptn.LoggerInterface) (*keptnevents.ServiceLevelObjectives, error) {
resourceHandler := configutils.NewResourceHandler(getConfigurationServiceURL())

resource, err := resourceHandler.GetServiceResource(eventData.Project, stage, eventData.Service, "slo.yaml")
resourceScope := configutils.NewResourceScope()
resourceScope.Project(eventData.Project)
resourceScope.Service(eventData.Service)
resourceScope.Stage(stage)
resourceScope.Resource("slo.yaml")

resource, err := resourceHandler.GetResource(*resourceScope)
if err != nil || resource.ResourceContent == "" {
return nil, errors.New("No SLO file available for service " + eventData.Service + " in stage " + stage)
}
Expand Down
12 changes: 6 additions & 6 deletions eventhandling/getSliEvent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func Test_retrieveMetrics(t *testing.T) {
err = incomingEvent.DataAs(eventData)
require.NoError(t, err)

apiMock := prometheusfake.NewMockPrometheusAPI(mockCtrl)
apiMock := prometheusfake.NewMockAPI(mockCtrl)
handler := prometheusUtils.Handler{
Project: eventData.Project,
Stage: eventData.Stage,
Expand All @@ -78,7 +78,7 @@ func Test_retrieveMetrics(t *testing.T) {

assert.Len(t, sliResults, 1)
assert.Contains(t, sliResults, &keptnv2.SLIResult{
Metric: Throughput,
Metric: prometheusUtils.Throughput,
Value: sliValue,
ComparedValue: 0,
Success: true,
Expand All @@ -99,7 +99,7 @@ func Test_retrieveMetricsWithMultipleValues(t *testing.T) {
err = incomingEvent.DataAs(eventData)
require.NoError(t, err)

apiMock := prometheusfake.NewMockPrometheusAPI(mockCtrl)
apiMock := prometheusfake.NewMockAPI(mockCtrl)
handler := prometheusUtils.Handler{
Project: eventData.Project,
Stage: eventData.Stage,
Expand All @@ -124,7 +124,7 @@ func Test_retrieveMetricsWithMultipleValues(t *testing.T) {

assert.Len(t, sliResults, 1)
assert.Contains(t, sliResults, &keptnv2.SLIResult{
Metric: Throughput,
Metric: prometheusUtils.Throughput,
Value: 0,
ComparedValue: 0,
Success: false,
Expand All @@ -145,7 +145,7 @@ func Test_retrieveMetricsWithNoValue(t *testing.T) {
err = incomingEvent.DataAs(eventData)
require.NoError(t, err)

apiMock := prometheusfake.NewMockPrometheusAPI(mockCtrl)
apiMock := prometheusfake.NewMockAPI(mockCtrl)
handler := prometheusUtils.Handler{
Project: eventData.Project,
Stage: eventData.Stage,
Expand All @@ -161,7 +161,7 @@ func Test_retrieveMetricsWithNoValue(t *testing.T) {

assert.Len(t, sliResults, 1)
assert.Contains(t, sliResults, &keptnv2.SLIResult{
Metric: Throughput,
Metric: prometheusUtils.Throughput,
Value: 0,
ComparedValue: 0,
Success: false,
Expand Down
73 changes: 36 additions & 37 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,81 @@ module github.com/keptn-contrib/prometheus-service
go 1.17

require (
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15
github.com/cloudevents/sdk-go/v2 v2.5.0
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137
github.com/cloudevents/sdk-go/v2 v2.9.0
github.com/golang/mock v1.6.0
github.com/google/uuid v1.3.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/keptn/go-utils v0.14.0
github.com/mitchellh/mapstructure v1.4.3
github.com/prometheus/alertmanager v0.23.0
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/common v0.32.0
github.com/mitchellh/mapstructure v1.5.0
github.com/prometheus/alertmanager v0.24.0
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/common v0.34.0
github.com/stretchr/testify v1.7.1
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.23.4
k8s.io/apimachinery v0.23.4
k8s.io/client-go v0.23.4
k8s.io/api v0.24.0
k8s.io/apimachinery v0.24.0
k8s.io/client-go v0.24.0
)

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/aws/aws-sdk-go v1.40.11 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/aws/aws-sdk-go v1.43.11 // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cloudevents/sdk-go/observability/opentelemetry/v2 v2.0.0-20211001212819-74757a691209 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/go-kit/log v0.1.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/go-kit/log v0.2.0 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common/sigv4 v0.1.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.27.0 // indirect
go.opentelemetry.io/otel v1.2.0 // indirect
go.opentelemetry.io/otel/internal/metric v0.25.0 // indirect
go.opentelemetry.io/otel/metric v0.25.0 // indirect
go.opentelemetry.io/otel/trace v1.2.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.3.0 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
go.uber.org/zap v1.13.0 // indirect
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.10.0 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.1.10 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/Azure/go-autorest => github.com/Azure/go-autorest v13.3.2+incompatible
)
Loading

0 comments on commit 96cf984

Please sign in to comment.