mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 13:29:01 +08:00
Merge pull request #699 from Tazer/fix-constants-alertmanager
fix: added support for custom alertmanager url
This commit is contained in:
commit
10f4fb53ac
@ -33,7 +33,9 @@ SigNoz helps developers monitor applications and troubleshoot problems in their
|
||||
👉 Run aggregates on trace data to get business relevant metrics
|
||||
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
<br /><br />
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 (
|
||||
|
20
pkg/query-service/constants/constants_test.go
Normal file
20
pkg/query-service/constants/constants_test.go
Normal file
@ -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/")
|
||||
})
|
||||
})
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user