Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix: use query-service API to fetch triggered alerts (#3417)

Srikanth Chekuri7586b50c5a73
diff --git a/deploy/docker-swarm/common/nginx-config.conf b/deploy/docker-swarm/common/nginx-config.conf
index 158effc8bf..f7943e21aa 100644
--- a/deploy/docker-swarm/common/nginx-config.conf
+++ b/deploy/docker-swarm/common/nginx-config.conf
@@ -24,10 +24,6 @@ server {
try_files $uri $uri/ /index.html;
}
- location /api/alertmanager {
- proxy_pass http://alertmanager:9093/api/v2;
- }
-
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
proxy_pass http://query-service:8080;
proxy_http_version 1.1;
diff --git a/deploy/docker/common/nginx-config.conf b/deploy/docker/common/nginx-config.conf
index 158effc8bf..f7943e21aa 100644
--- a/deploy/docker/common/nginx-config.conf
+++ b/deploy/docker/common/nginx-config.conf
@@ -24,10 +24,6 @@ server {
try_files $uri $uri/ /index.html;
}
- location /api/alertmanager {
- proxy_pass http://alertmanager:9093/api/v2;
- }
-
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
proxy_pass http://query-service:8080;
proxy_http_version 1.1;
diff --git a/frontend/src/api/alerts/getTriggered.ts b/frontend/src/api/alerts/getTriggered.ts
index 160b9a3b93..6955cc315c 100644
--- a/frontend/src/api/alerts/getTriggered.ts
+++ b/frontend/src/api/alerts/getTriggered.ts
@@ -1,4 +1,4 @@
-import { AxiosAlertManagerInstance } from 'api';
+import axios from 'api';
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
import { AxiosError } from 'axios';
import convertObjectIntoParams from 'lib/query/convertObjectIntoParams';
@@ -11,15 +11,15 @@ const getTriggered = async (
try {
const queryParams = convertObjectIntoParams(props);
- const response = await AxiosAlertManagerInstance.get(
- `/alerts?${queryParams}`,
- );
+ const response = await axios.get(`/alerts?${queryParams}`);
+
+ const amData = JSON.parse(response.data.data);
return {
statusCode: 200,
error: null,
message: response.data.status,
- payload: response.data,
+ payload: amData.data,
};
} catch (error) {
return ErrorResponseHandler(error as AxiosError);
diff --git a/pkg/query-service/app/http_handler.go b/pkg/query-service/app/http_handler.go
index 46029a9e39..fa55154ac2 100644
--- a/pkg/query-service/app/http_handler.go
+++ b/pkg/query-service/app/http_handler.go
@@ -319,6 +319,8 @@ func (aH *APIHandler) RegisterRoutes(router *mux.Router, am *AuthMiddleware) {
router.HandleFunc("/api/v1/channels", am.EditAccess(aH.createChannel)).Methods(http.MethodPost)
router.HandleFunc("/api/v1/testChannel", am.EditAccess(aH.testChannel)).Methods(http.MethodPost)
+ router.HandleFunc("/api/v1/alerts", am.ViewAccess(aH.getAlerts)).Methods(http.MethodGet)
+
router.HandleFunc("/api/v1/rules", am.ViewAccess(aH.listRules)).Methods(http.MethodGet)
router.HandleFunc("/api/v1/rules/{id}", am.ViewAccess(aH.getRule)).Methods(http.MethodGet)
router.HandleFunc("/api/v1/rules", am.EditAccess(aH.createRule)).Methods(http.MethodPost)
@@ -1195,6 +1197,25 @@ func (aH *APIHandler) createChannel(w http.ResponseWriter, r *http.Request) {
}
+func (aH *APIHandler) getAlerts(w http.ResponseWriter, r *http.Request) {
+ params := r.URL.Query()
+ amEndpoint := constants.GetAlertManagerApiPrefix()
+ resp, err := http.Get(amEndpoint + "v1/alerts" + "?" + params.Encode())
+ if err != nil {
+ RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)
+ return
+ }
+
+ defer resp.Body.Close()
+ body, err := io.ReadAll(resp.Body)
+ if err != nil {
+ RespondError(w, &model.ApiError{Typ: model.ErrorInternal, Err: err}, nil)
+ return
+ }
+
+ aH.Respond(w, string(body))
+}
+
func (aH *APIHandler) createRule(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()