mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-27 04:42:01 +08:00
Merge branch 'develop' into issue-3400-ui-horizontal-scroll-logs-context
This commit is contained in:
commit
23f94538c8
@ -24,10 +24,6 @@ server {
|
|||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/alertmanager {
|
|
||||||
proxy_pass http://alertmanager:9093/api/v2;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
|
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
|
||||||
proxy_pass http://query-service:8080;
|
proxy_pass http://query-service:8080;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
@ -24,10 +24,6 @@ server {
|
|||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/alertmanager {
|
|
||||||
proxy_pass http://alertmanager:9093/api/v2;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
|
location ~ ^/api/(v1|v3)/logs/(tail|livetail){
|
||||||
proxy_pass http://query-service:8080;
|
proxy_pass http://query-service:8080;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AxiosAlertManagerInstance } from 'api';
|
import axios from 'api';
|
||||||
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
import { ErrorResponseHandler } from 'api/ErrorResponseHandler';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import convertObjectIntoParams from 'lib/query/convertObjectIntoParams';
|
import convertObjectIntoParams from 'lib/query/convertObjectIntoParams';
|
||||||
@ -11,15 +11,15 @@ const getTriggered = async (
|
|||||||
try {
|
try {
|
||||||
const queryParams = convertObjectIntoParams(props);
|
const queryParams = convertObjectIntoParams(props);
|
||||||
|
|
||||||
const response = await AxiosAlertManagerInstance.get(
|
const response = await axios.get(`/alerts?${queryParams}`);
|
||||||
`/alerts?${queryParams}`,
|
|
||||||
);
|
const amData = JSON.parse(response.data.data);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
error: null,
|
error: null,
|
||||||
message: response.data.status,
|
message: response.data.status,
|
||||||
payload: response.data,
|
payload: amData.data,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return ErrorResponseHandler(error as AxiosError);
|
return ErrorResponseHandler(error as AxiosError);
|
||||||
|
@ -49,7 +49,7 @@ func InitDB(dataSourceName string) (*sqlx.DB, error) {
|
|||||||
|
|
||||||
_, err = db.Exec(table_schema)
|
_, err = db.Exec(table_schema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error in creating dashboard table: %s", err.Error())
|
return nil, fmt.Errorf("error in creating dashboard table: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
table_schema = `CREATE TABLE IF NOT EXISTS rules (
|
table_schema = `CREATE TABLE IF NOT EXISTS rules (
|
||||||
@ -61,7 +61,7 @@ func InitDB(dataSourceName string) (*sqlx.DB, error) {
|
|||||||
|
|
||||||
_, err = db.Exec(table_schema)
|
_, err = db.Exec(table_schema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error in creating rules table: %s", err.Error())
|
return nil, fmt.Errorf("error in creating rules table: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
table_schema = `CREATE TABLE IF NOT EXISTS notification_channels (
|
table_schema = `CREATE TABLE IF NOT EXISTS notification_channels (
|
||||||
@ -76,7 +76,7 @@ func InitDB(dataSourceName string) (*sqlx.DB, error) {
|
|||||||
|
|
||||||
_, err = db.Exec(table_schema)
|
_, err = db.Exec(table_schema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error in creating notification_channles table: %s", err.Error())
|
return nil, fmt.Errorf("error in creating notification_channles table: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
table_schema = `CREATE TABLE IF NOT EXISTS ttl_status (
|
table_schema = `CREATE TABLE IF NOT EXISTS ttl_status (
|
||||||
@ -92,7 +92,7 @@ func InitDB(dataSourceName string) (*sqlx.DB, error) {
|
|||||||
|
|
||||||
_, err = db.Exec(table_schema)
|
_, err = db.Exec(table_schema)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Error in creating ttl_status table: %s", err.Error())
|
return nil, fmt.Errorf("error in creating ttl_status table: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return db, nil
|
return db, nil
|
||||||
@ -179,7 +179,7 @@ func CreateDashboard(data map[string]interface{}, fm interfaces.FeatureLookup) (
|
|||||||
func GetDashboards() ([]Dashboard, *model.ApiError) {
|
func GetDashboards() ([]Dashboard, *model.ApiError) {
|
||||||
|
|
||||||
dashboards := []Dashboard{}
|
dashboards := []Dashboard{}
|
||||||
query := fmt.Sprintf("SELECT * FROM dashboards;")
|
query := `SELECT * FROM dashboards`
|
||||||
|
|
||||||
err := db.Select(&dashboards, query)
|
err := db.Select(&dashboards, query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -197,9 +197,9 @@ func DeleteDashboard(uuid string, fm interfaces.FeatureLookup) *model.ApiError {
|
|||||||
return dErr
|
return dErr
|
||||||
}
|
}
|
||||||
|
|
||||||
query := fmt.Sprintf("DELETE FROM dashboards WHERE uuid='%s';", uuid)
|
query := `DELETE FROM dashboards WHERE uuid=?`
|
||||||
|
|
||||||
result, err := db.Exec(query)
|
result, err := db.Exec(query, uuid)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &model.ApiError{Typ: model.ErrorExec, Err: err}
|
return &model.ApiError{Typ: model.ErrorExec, Err: err}
|
||||||
@ -224,9 +224,9 @@ func DeleteDashboard(uuid string, fm interfaces.FeatureLookup) *model.ApiError {
|
|||||||
func GetDashboard(uuid string) (*Dashboard, *model.ApiError) {
|
func GetDashboard(uuid string) (*Dashboard, *model.ApiError) {
|
||||||
|
|
||||||
dashboard := Dashboard{}
|
dashboard := Dashboard{}
|
||||||
query := fmt.Sprintf("SELECT * FROM dashboards WHERE uuid='%s';", uuid)
|
query := `SELECT * FROM dashboards WHERE uuid=?`
|
||||||
|
|
||||||
err := db.Get(&dashboard, query)
|
err := db.Get(&dashboard, query, uuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("no dashboard found with uuid: %s", uuid)}
|
return nil, &model.ApiError{Typ: model.ErrorNotFound, Err: fmt.Errorf("no dashboard found with uuid: %s", uuid)}
|
||||||
}
|
}
|
||||||
|
@ -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/channels", am.EditAccess(aH.createChannel)).Methods(http.MethodPost)
|
||||||
router.HandleFunc("/api/v1/testChannel", am.EditAccess(aH.testChannel)).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", 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/{id}", am.ViewAccess(aH.getRule)).Methods(http.MethodGet)
|
||||||
router.HandleFunc("/api/v1/rules", am.EditAccess(aH.createRule)).Methods(http.MethodPost)
|
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) {
|
func (aH *APIHandler) createRule(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user