mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-18 14:31:30 +08:00

* feat(explorer): updated metadata metrics api| 7076 * feat(explorer): added inspect metrics with resource attribute| 7076 * fix(summary): fixed dashboard name in metric metadata api * fix(summary): removed offset from second query * fix(summary): removed offset from second query * feat(summary): added update metrics metadata api * feat(summary): resolved log messages * feat(summary): added is_monotonic column and added temporality| 7077 * feat(summary): added histogram bucket and summary quantile check| 7077 * feat(summary): added temporality and is_monotonic in update queries| 7077 * feat(summary): resolved pr comments| 7077 * feat(inspect): normalized resource attributes * feat(update-summary): merge conflicts resolve * feat(update-summary): merge conflicts resolve * feat(update-metrics): updated description check * feat(update-metrics): added kv log comments * fix: updated testcase with reader * fix: updated testcase with reader * fix: updated testcase with reader * fix: updated normalized true in metrics explorer api * fix: removed inner join from list metrics query
165 lines
5.0 KiB
Go
165 lines
5.0 KiB
Go
package app
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
"go.signoz.io/signoz/pkg/query-service/model"
|
|
|
|
explorer "go.signoz.io/signoz/pkg/query-service/app/metricsexplorer"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func (aH *APIHandler) FilterKeysSuggestion(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseFilterKeySuggestions(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing summary filter keys request", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
keys, apiError := aH.SummaryService.FilterKeys(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting filter keys", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, keys)
|
|
}
|
|
|
|
func (aH *APIHandler) FilterValuesSuggestion(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseFilterValueSuggestions(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing summary filter values request", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
|
|
values, apiError := aH.SummaryService.FilterValues(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting filter values", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, values)
|
|
}
|
|
|
|
func (aH *APIHandler) GetMetricsDetails(w http.ResponseWriter, r *http.Request) {
|
|
metricName := mux.Vars(r)["metric_name"]
|
|
ctx := r.Context()
|
|
metricsDetail, apiError := aH.SummaryService.GetMetricsSummary(ctx, metricName)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting metrics summary error", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, metricsDetail)
|
|
}
|
|
|
|
func (aH *APIHandler) ListMetrics(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseSummaryListMetricsParams(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing metric list metric summary api request", zap.Error(apiError.Err))
|
|
RespondError(w, model.BadRequest(apiError), nil)
|
|
return
|
|
}
|
|
|
|
slmr, apiErr := aH.SummaryService.ListMetricsWithSummary(ctx, params)
|
|
if apiErr != nil {
|
|
zap.L().Error("error parsing metric query range params", zap.Error(apiErr.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, slmr)
|
|
}
|
|
|
|
func (aH *APIHandler) GetTreeMap(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseTreeMapMetricsParams(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing heatmap metric params", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
result, apiError := aH.SummaryService.GetMetricsTreemap(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting heatmap data", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, result)
|
|
|
|
}
|
|
|
|
func (aH *APIHandler) GetRelatedMetrics(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseRelatedMetricsParams(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing related metric params", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
result, apiError := aH.SummaryService.GetRelatedMetrics(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting related metrics", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, result)
|
|
|
|
}
|
|
|
|
func (aH *APIHandler) GetInspectMetricsData(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseInspectMetricsParams(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing inspect metric params", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
result, apiError := aH.SummaryService.GetInspectMetrics(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error getting inspect metrics data", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, result)
|
|
|
|
}
|
|
|
|
func (aH *APIHandler) UpdateMetricsMetadata(w http.ResponseWriter, r *http.Request) {
|
|
bodyBytes, _ := io.ReadAll(r.Body)
|
|
r.Body = io.NopCloser(bytes.NewBuffer(bodyBytes))
|
|
ctx := r.Context()
|
|
params, apiError := explorer.ParseUpdateMetricsMetadataParams(r)
|
|
if apiError != nil {
|
|
zap.L().Error("error parsing update metrics metadata params", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
apiError = aH.SummaryService.UpdateMetricsMetadata(ctx, params)
|
|
if apiError != nil {
|
|
zap.L().Error("error updating metrics metadata", zap.Error(apiError.Err))
|
|
RespondError(w, apiError, nil)
|
|
return
|
|
}
|
|
aH.Respond(w, nil)
|
|
|
|
}
|