From d7fa503f049ecdafd3ff7ae6d16b2dc2d615df20 Mon Sep 17 00:00:00 2001 From: Pranay Prateek Date: Thu, 10 Feb 2022 00:28:00 +0530 Subject: [PATCH 1/2] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e7af0d5bef..6bc8fec353 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,9 @@ SigNoz helps developers monitor applications and troubleshoot problems in their 👉 Run aggregates on trace data to get business relevant metrics -![SigNoz Feature](https://signoz-public.s3.us-east-2.amazonaws.com/signoz_hero_github.png) +![screenzy-1644432902955](https://user-images.githubusercontent.com/504541/153270713-1b2156e6-ec03-42de-975b-3c02b8ec1836.png) + +![screenzy-1644432986784](https://user-images.githubusercontent.com/504541/153270725-0efb73b3-06ed-4207-bf13-9b7e2e17c4b8.png)

From fdc8670fab202288689b690b1445186c969ceeb2 Mon Sep 17 00:00:00 2001 From: Patrik Date: Wed, 9 Feb 2022 22:05:27 +0100 Subject: [PATCH 2/2] fix: added support for custom alertmanager url --- .../app/clickhouseReader/reader.go | 8 ++++---- pkg/query-service/constants/constants.go | 8 +++++++- pkg/query-service/constants/constants_test.go | 20 +++++++++++++++++++ 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 pkg/query-service/constants/constants_test.go diff --git a/pkg/query-service/app/clickhouseReader/reader.go b/pkg/query-service/app/clickhouseReader/reader.go index ab124de5e9..876c66fa18 100644 --- a/pkg/query-service/app/clickhouseReader/reader.go +++ b/pkg/query-service/app/clickhouseReader/reader.go @@ -660,7 +660,7 @@ func (r *ClickHouseReader) LoadChannel(channel *model.ChannelItem) *model.ApiErr return &model.ApiError{Typ: model.ErrorBadData, Err: err} } - response, err := http.Post(constants.ALERTMANAGER_API_PREFIX+"v1/receivers", "application/json", bytes.NewBuffer([]byte(channel.Data))) + response, err := http.Post(constants.GetAlertManagerApiPrefix()+"v1/receivers", "application/json", bytes.NewBuffer([]byte(channel.Data))) if err != nil { zap.S().Errorf("Error in getting response of API call to alertmanager/v1/receivers\n", err) @@ -730,7 +730,7 @@ func (r *ClickHouseReader) DeleteChannel(id string) *model.ApiError { values := map[string]string{"name": channelToDelete.Name} jsonValue, _ := json.Marshal(values) - req, err := http.NewRequest(http.MethodDelete, constants.ALERTMANAGER_API_PREFIX+"v1/receivers", bytes.NewBuffer(jsonValue)) + req, err := http.NewRequest(http.MethodDelete, constants.GetAlertManagerApiPrefix()+"v1/receivers", bytes.NewBuffer(jsonValue)) if err != nil { zap.S().Errorf("Error in creating new delete request to alertmanager/v1/receivers\n", err) @@ -855,7 +855,7 @@ func (r *ClickHouseReader) EditChannel(receiver *model.Receiver, id string) (*mo } } - req, err := http.NewRequest(http.MethodPut, constants.ALERTMANAGER_API_PREFIX+"v1/receivers", bytes.NewBuffer(receiverString)) + req, err := http.NewRequest(http.MethodPut, constants.GetAlertManagerApiPrefix()+"v1/receivers", bytes.NewBuffer(receiverString)) if err != nil { zap.S().Errorf("Error in creating new update request to alertmanager/v1/receivers\n", err) @@ -917,7 +917,7 @@ func (r *ClickHouseReader) CreateChannel(receiver *model.Receiver) (*model.Recei } } - response, err := http.Post(constants.ALERTMANAGER_API_PREFIX+"v1/receivers", "application/json", bytes.NewBuffer(receiverString)) + response, err := http.Post(constants.GetAlertManagerApiPrefix()+"v1/receivers", "application/json", bytes.NewBuffer(receiverString)) if err != nil { zap.S().Errorf("Error in getting response of API call to alertmanager/v1/receivers\n", err) diff --git a/pkg/query-service/constants/constants.go b/pkg/query-service/constants/constants.go index 3339432513..0e19f83f93 100644 --- a/pkg/query-service/constants/constants.go +++ b/pkg/query-service/constants/constants.go @@ -23,7 +23,13 @@ func IsTelemetryEnabled() bool { const TraceTTL = "traces" const MetricsTTL = "metrics" -const ALERTMANAGER_API_PREFIX = "http://alertmanager:9093/api/" +func GetAlertManagerApiPrefix() string { + if os.Getenv("ALERTMANAGER_API_PREFIX") != "" { + return os.Getenv("ALERTMANAGER_API_PREFIX") + } + return "http://alertmanager:9093/api/" +} + const RELATIONAL_DATASOURCE_PATH = "/var/lib/signoz/signoz.db" const ( diff --git a/pkg/query-service/constants/constants_test.go b/pkg/query-service/constants/constants_test.go new file mode 100644 index 0000000000..97bed19271 --- /dev/null +++ b/pkg/query-service/constants/constants_test.go @@ -0,0 +1,20 @@ +package constants + +import ( + . "github.com/smartystreets/goconvey/convey" + "os" + "testing" +) + +func TestGetAlertManagerApiPrefix(t *testing.T) { + Convey("TestGetAlertManagerApiPrefix", t, func() { + res := GetAlertManagerApiPrefix() + So(res, ShouldEqual, "http://alertmanager:9093/api/") + + Convey("WithEnvSet", func() { + os.Setenv("ALERTMANAGER_API_PREFIX", "http://test:9093/api/") + res = GetAlertManagerApiPrefix() + So(res, ShouldEqual, "http://test:9093/api/") + }) + }) +}