mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-08 06:48:58 +08:00
Merge branch 'develop' into 1249-service-tab
This commit is contained in:
commit
c6d57a7a53
@ -28,7 +28,7 @@ services:
|
||||
volumes:
|
||||
- ./data/alertmanager:/data
|
||||
command:
|
||||
- --queryService.url=http://query-service:8080
|
||||
- --queryService.url=http://query-service:8085
|
||||
- --storage.path=/data
|
||||
depends_on:
|
||||
- query-service
|
||||
@ -37,7 +37,7 @@ services:
|
||||
condition: on-failure
|
||||
|
||||
query-service:
|
||||
image: signoz/query-service:0.8.0
|
||||
image: signoz/query-service:0.8.1
|
||||
command: ["-config=/root/config/prometheus.yml"]
|
||||
# ports:
|
||||
# - "6060:6060" # pprof port
|
||||
@ -65,7 +65,7 @@ services:
|
||||
- clickhouse
|
||||
|
||||
frontend:
|
||||
image: signoz/frontend:0.8.0
|
||||
image: signoz/frontend:0.8.1
|
||||
deploy:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
@ -78,7 +78,7 @@ services:
|
||||
- ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf
|
||||
|
||||
otel-collector:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
@ -104,7 +104,7 @@ services:
|
||||
- clickhouse
|
||||
|
||||
otel-collector-metrics:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-metrics-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml
|
||||
|
@ -52,7 +52,7 @@ extensions:
|
||||
health_check: {}
|
||||
zpages: {}
|
||||
exporters:
|
||||
clickhouse:
|
||||
clickhousetraces:
|
||||
datasource: tcp://clickhouse:9000/?database=signoz_traces
|
||||
clickhousemetricswrite:
|
||||
endpoint: tcp://clickhouse:9000/?database=signoz_metrics
|
||||
@ -66,7 +66,7 @@ service:
|
||||
traces:
|
||||
receivers: [jaeger, otlp]
|
||||
processors: [signozspanmetrics/prometheus, batch]
|
||||
exporters: [clickhouse]
|
||||
exporters: [clickhousetraces]
|
||||
metrics:
|
||||
receivers: [otlp, hostmetrics]
|
||||
processors: [batch]
|
||||
|
@ -30,14 +30,14 @@ services:
|
||||
condition: service_healthy
|
||||
restart: on-failure
|
||||
command:
|
||||
- --queryService.url=http://query-service:8080
|
||||
- --queryService.url=http://query-service:8085
|
||||
- --storage.path=/data
|
||||
|
||||
# Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md`
|
||||
|
||||
|
||||
query-service:
|
||||
image: signoz/query-service:0.8.0
|
||||
image: signoz/query-service:0.8.1
|
||||
container_name: query-service
|
||||
command: ["-config=/root/config/prometheus.yml"]
|
||||
# ports:
|
||||
@ -53,7 +53,6 @@ services:
|
||||
- GODEBUG=netdns=go
|
||||
- TELEMETRY_ENABLED=true
|
||||
- DEPLOYMENT_TYPE=docker-standalone-arm
|
||||
|
||||
restart: on-failure
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--spider", "-q", "localhost:8080/api/v1/version"]
|
||||
@ -65,7 +64,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
frontend:
|
||||
image: signoz/frontend:0.8.0
|
||||
image: signoz/frontend:0.8.1
|
||||
container_name: frontend
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
@ -77,7 +76,7 @@ services:
|
||||
- ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf
|
||||
|
||||
otel-collector:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
@ -98,7 +97,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector-metrics:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-metrics-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml
|
||||
|
@ -30,13 +30,13 @@ services:
|
||||
condition: service_healthy
|
||||
restart: on-failure
|
||||
command:
|
||||
- --queryService.url=http://query-service:8080
|
||||
- --queryService.url=http://query-service:8085
|
||||
- --storage.path=/data
|
||||
|
||||
# Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md`
|
||||
|
||||
query-service:
|
||||
image: signoz/query-service:0.8.0
|
||||
image: signoz/query-service:0.8.1
|
||||
container_name: query-service
|
||||
command: ["-config=/root/config/prometheus.yml"]
|
||||
# ports:
|
||||
@ -63,7 +63,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
frontend:
|
||||
image: signoz/frontend:0.8.0
|
||||
image: signoz/frontend:0.8.1
|
||||
container_name: frontend
|
||||
restart: on-failure
|
||||
depends_on:
|
||||
@ -75,7 +75,7 @@ services:
|
||||
- ../common/nginx-config.conf:/etc/nginx/conf.d/default.conf
|
||||
|
||||
otel-collector:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
@ -96,7 +96,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector-metrics:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-metrics-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml
|
||||
|
@ -52,7 +52,7 @@ extensions:
|
||||
health_check: {}
|
||||
zpages: {}
|
||||
exporters:
|
||||
clickhouse:
|
||||
clickhousetraces:
|
||||
datasource: tcp://clickhouse:9000/?database=signoz_traces
|
||||
clickhousemetricswrite:
|
||||
endpoint: tcp://clickhouse:9000/?database=signoz_metrics
|
||||
@ -66,7 +66,7 @@ service:
|
||||
traces:
|
||||
receivers: [jaeger, otlp]
|
||||
processors: [signozspanmetrics/prometheus, batch]
|
||||
exporters: [clickhouse]
|
||||
exporters: [clickhousetraces]
|
||||
metrics:
|
||||
receivers: [otlp, hostmetrics]
|
||||
processors: [batch]
|
||||
|
@ -29,12 +29,15 @@ function GraphLayout({
|
||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||
const { isDarkMode } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||
|
||||
const [saveLayout] = useComponentPermission(['save_layout'], role);
|
||||
const [saveLayoutPermission, addPanelPermission] = useComponentPermission(
|
||||
['save_layout', 'add_panel'],
|
||||
role,
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<ButtonContainer>
|
||||
{saveLayout && (
|
||||
{saveLayoutPermission && (
|
||||
<Button
|
||||
loading={saveLayoutState.loading}
|
||||
onClick={(): Promise<void> => onLayoutSaveHandler(layouts)}
|
||||
@ -45,6 +48,7 @@ function GraphLayout({
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{addPanelPermission && (
|
||||
<Button
|
||||
loading={addPanelLoading}
|
||||
disabled={addPanelLoading}
|
||||
@ -53,16 +57,17 @@ function GraphLayout({
|
||||
>
|
||||
Add Panel
|
||||
</Button>
|
||||
)}
|
||||
</ButtonContainer>
|
||||
|
||||
<ReactGridLayout
|
||||
isResizable
|
||||
cols={12}
|
||||
rowHeight={100}
|
||||
autoSize
|
||||
width={100}
|
||||
isDraggable
|
||||
isDroppable
|
||||
isDraggable={addPanelPermission}
|
||||
isDroppable={addPanelPermission}
|
||||
isResizable={addPanelPermission}
|
||||
useCSSTransforms
|
||||
allowOverlap={false}
|
||||
onLayoutChange={onLayoutChangeHandler}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* eslint-disable react/no-unstable-nested-components */
|
||||
import { notification } from 'antd';
|
||||
import updateDashboardApi from 'api/dashboard/update';
|
||||
import useComponentPermission from 'hooks/useComponentPermission';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import { Layout } from 'react-grid-layout';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
@ -15,6 +16,7 @@ import { AppState } from 'store/reducers';
|
||||
import AppActions from 'types/actions';
|
||||
import { UPDATE_DASHBOARD } from 'types/actions/dashboard';
|
||||
import { Dashboard, Widgets } from 'types/api/dashboard/getAll';
|
||||
import AppReducer from 'types/reducer/app';
|
||||
import DashboardReducer from 'types/reducer/dashboards';
|
||||
|
||||
import Graph from './Graph';
|
||||
@ -49,6 +51,9 @@ function GridGraph(props: Props): JSX.Element {
|
||||
const { dashboards, isAddWidget } = useSelector<AppState, DashboardReducer>(
|
||||
(state) => state.dashboards,
|
||||
);
|
||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||
|
||||
const [saveLayoutPermission] = useComponentPermission(['save_layout'], role);
|
||||
const [saveLayoutState, setSaveLayoutState] = useState<State>({
|
||||
loading: false,
|
||||
error: false,
|
||||
@ -109,6 +114,8 @@ function GridGraph(props: Props): JSX.Element {
|
||||
loading: true,
|
||||
}));
|
||||
|
||||
// Save layout only when users has the has the permission to do so.
|
||||
if (saveLayoutPermission) {
|
||||
const response = await updateDashboardApi({
|
||||
data: {
|
||||
title: data.title,
|
||||
@ -135,6 +142,7 @@ function GridGraph(props: Props): JSX.Element {
|
||||
loading: false,
|
||||
}));
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
@ -145,6 +153,7 @@ function GridGraph(props: Props): JSX.Element {
|
||||
data.tags,
|
||||
data.title,
|
||||
data.widgets,
|
||||
saveLayoutPermission,
|
||||
selectedDashboard.uuid,
|
||||
],
|
||||
);
|
||||
|
@ -15,11 +15,19 @@ import ROUTES from 'constants/routes';
|
||||
import SearchFilter from 'container/ListOfDashboard/SearchFilter';
|
||||
import useComponentPermission from 'hooks/useComponentPermission';
|
||||
import history from 'lib/history';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, {
|
||||
Dispatch,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { generatePath } from 'react-router-dom';
|
||||
import { AppState } from 'store/reducers';
|
||||
import AppActions from 'types/actions';
|
||||
import { GET_ALL_DASHBOARD_SUCCESS } from 'types/actions/dashboard';
|
||||
import { Dashboard } from 'types/api/dashboard/getAll';
|
||||
import AppReducer from 'types/reducer/app';
|
||||
import DashboardReducer from 'types/reducer/dashboards';
|
||||
@ -36,6 +44,7 @@ function ListOfAllDashboard(): JSX.Element {
|
||||
const { dashboards, loading } = useSelector<AppState, DashboardReducer>(
|
||||
(state) => state.dashboards,
|
||||
);
|
||||
const dispatch = useDispatch<Dispatch<AppActions>>();
|
||||
const { role } = useSelector<AppState, AppReducer>((state) => state.app);
|
||||
|
||||
const [action, createNewDashboard, newDashboard] = useComponentPermission(
|
||||
@ -131,6 +140,10 @@ function ListOfAllDashboard(): JSX.Element {
|
||||
});
|
||||
|
||||
if (response.statusCode === 200) {
|
||||
dispatch({
|
||||
type: GET_ALL_DASHBOARD_SUCCESS,
|
||||
payload: [],
|
||||
});
|
||||
history.push(
|
||||
generatePath(ROUTES.DASHBOARD, {
|
||||
dashboardId: response.payload.uuid,
|
||||
@ -151,7 +164,7 @@ function ListOfAllDashboard(): JSX.Element {
|
||||
errorMessage: (error as AxiosError).toString() || 'Something went Wrong',
|
||||
});
|
||||
}
|
||||
}, [newDashboardState, t]);
|
||||
}, [newDashboardState, t, dispatch]);
|
||||
|
||||
const getText = useCallback(() => {
|
||||
if (!newDashboardState.error && !newDashboardState.loading) {
|
||||
|
@ -66,7 +66,7 @@ export const RedDot = styled.div`
|
||||
background: #d32029;
|
||||
border-radius: 50%;
|
||||
|
||||
margin-left: 1rem;
|
||||
margin-left: 0.5rem;
|
||||
margin-top: 0.5rem;
|
||||
`;
|
||||
|
||||
|
@ -16,7 +16,8 @@ export type ComponentTypes =
|
||||
| 'delete_widget'
|
||||
| 'new_dashboard'
|
||||
| 'new_alert_action'
|
||||
| 'edit_widget';
|
||||
| 'edit_widget'
|
||||
| 'add_panel';
|
||||
|
||||
export const componentPermission: Record<ComponentTypes, ROLES[]> = {
|
||||
current_org_settings: ['ADMIN'],
|
||||
@ -34,6 +35,7 @@ export const componentPermission: Record<ComponentTypes, ROLES[]> = {
|
||||
new_dashboard: ['ADMIN', 'EDITOR'],
|
||||
new_alert_action: ['ADMIN'],
|
||||
edit_widget: ['ADMIN', 'EDITOR'],
|
||||
add_panel: ['ADMIN', 'EDITOR'],
|
||||
};
|
||||
|
||||
export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {
|
||||
@ -47,7 +49,7 @@ export const routePermission: Record<keyof typeof ROUTES, ROLES[]> = {
|
||||
APPLICATION: ['ADMIN', 'EDITOR', 'VIEWER'],
|
||||
CHANNELS_EDIT: ['ADMIN'],
|
||||
CHANNELS_NEW: ['ADMIN'],
|
||||
DASHBOARD: ['ADMIN', 'EDITOR', 'EDITOR'],
|
||||
DASHBOARD: ['ADMIN', 'EDITOR', 'VIEWER'],
|
||||
DASHBOARD_WIDGET: ['ADMIN', 'EDITOR', 'VIEWER'],
|
||||
EDIT_ALERTS: ['ADMIN'],
|
||||
ERROR_DETAIL: ['ADMIN', 'EDITOR', 'VIEWER'],
|
||||
|
@ -277,6 +277,11 @@ func AdminAccess(f func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// RegisterPrivateRoutes registers routes for this handler on the given router
|
||||
func (aH *APIHandler) RegisterPrivateRoutes(router *mux.Router) {
|
||||
router.HandleFunc("/api/v1/channels", aH.listChannels).Methods(http.MethodGet)
|
||||
}
|
||||
|
||||
// RegisterRoutes registers routes for this handler on the given router
|
||||
func (aH *APIHandler) RegisterRoutes(router *mux.Router) {
|
||||
router.HandleFunc("/api/v1/query_range", ViewAccess(aH.queryRangeMetrics)).Methods(http.MethodGet)
|
||||
|
@ -26,22 +26,23 @@ import (
|
||||
|
||||
type ServerOptions struct {
|
||||
HTTPHostPort string
|
||||
PrivateHostPort string
|
||||
}
|
||||
|
||||
// Server runs HTTP, Mux and a grpc server
|
||||
type Server struct {
|
||||
// logger *zap.Logger
|
||||
// querySvc *querysvc.QueryService
|
||||
// queryOptions *QueryOptions
|
||||
|
||||
// tracer opentracing.Tracer // TODO make part of flags.Service
|
||||
serverOptions *ServerOptions
|
||||
conn net.Listener
|
||||
// grpcConn net.Listener
|
||||
|
||||
// public http router
|
||||
httpConn net.Listener
|
||||
// grpcServer *grpc.Server
|
||||
httpServer *http.Server
|
||||
separatePorts bool
|
||||
|
||||
// private http
|
||||
privateConn net.Listener
|
||||
privateHTTP *http.Server
|
||||
|
||||
unavailableChannel chan healthcheck.Status
|
||||
}
|
||||
|
||||
@ -51,59 +52,20 @@ func (s Server) HealthCheckStatus() chan healthcheck.Status {
|
||||
}
|
||||
|
||||
// NewServer creates and initializes Server
|
||||
// func NewServer(logger *zap.Logger, querySvc *querysvc.QueryService, options *QueryOptions, tracer opentracing.Tracer) (*Server, error) {
|
||||
func NewServer(serverOptions *ServerOptions) (*Server, error) {
|
||||
|
||||
// _, httpPort, err := net.SplitHostPort(serverOptions.HTTPHostPort)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// _, grpcPort, err := net.SplitHostPort(options.GRPCHostPort)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
// grpcServer, err := createGRPCServer(querySvc, options, logger, tracer)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
if err := dao.InitDao("sqlite", constants.RELATIONAL_DATASOURCE_PATH); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &Server{
|
||||
// logger: logger,
|
||||
// querySvc: querySvc,
|
||||
// queryOptions: options,
|
||||
// tracer: tracer,
|
||||
// grpcServer: grpcServer,
|
||||
serverOptions: serverOptions,
|
||||
separatePorts: true,
|
||||
// separatePorts: grpcPort != httpPort,
|
||||
unavailableChannel: make(chan healthcheck.Status),
|
||||
}
|
||||
httpServer, err := s.createHTTPServer()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s.httpServer = httpServer
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (s *Server) createHTTPServer() (*http.Server, error) {
|
||||
|
||||
localDB, err := dashboards.InitDB(constants.RELATIONAL_DATASOURCE_PATH)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
localDB.SetMaxOpenConns(10)
|
||||
|
||||
var reader Reader
|
||||
|
||||
storage := os.Getenv("STORAGE")
|
||||
if storage == "clickhouse" {
|
||||
zap.S().Info("Using ClickHouse as datastore ...")
|
||||
@ -119,24 +81,75 @@ func (s *Server) createHTTPServer() (*http.Server, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := &Server{
|
||||
// logger: logger,
|
||||
// tracer: tracer,
|
||||
serverOptions: serverOptions,
|
||||
unavailableChannel: make(chan healthcheck.Status),
|
||||
}
|
||||
|
||||
httpServer, err := s.createPublicServer(apiHandler)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.httpServer = httpServer
|
||||
|
||||
privateServer, err := s.createPrivateServer(apiHandler)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.privateHTTP = privateServer
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (s *Server) createPrivateServer(api *APIHandler) (*http.Server, error) {
|
||||
|
||||
r := NewRouter()
|
||||
|
||||
r.Use(setTimeoutMiddleware)
|
||||
r.Use(s.analyticsMiddleware)
|
||||
r.Use(loggingMiddlewarePrivate)
|
||||
|
||||
api.RegisterPrivateRoutes(r)
|
||||
|
||||
c := cors.New(cors.Options{
|
||||
//todo(amol): find out a way to add exact domain or
|
||||
// ip here for alert manager
|
||||
AllowedOrigins: []string{"*"},
|
||||
AllowedMethods: []string{"GET", "DELETE", "POST", "PUT"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
})
|
||||
|
||||
handler := c.Handler(r)
|
||||
handler = handlers.CompressHandler(handler)
|
||||
|
||||
return &http.Server{
|
||||
Handler: handler,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *Server) createPublicServer(api *APIHandler) (*http.Server, error) {
|
||||
|
||||
r := NewRouter()
|
||||
|
||||
r.Use(setTimeoutMiddleware)
|
||||
r.Use(s.analyticsMiddleware)
|
||||
r.Use(loggingMiddleware)
|
||||
|
||||
apiHandler.RegisterRoutes(r)
|
||||
apiHandler.RegisterMetricsRoutes(r)
|
||||
api.RegisterRoutes(r)
|
||||
api.RegisterMetricsRoutes(r)
|
||||
|
||||
c := cors.New(cors.Options{
|
||||
AllowedOrigins: []string{"*"},
|
||||
// AllowCredentials: true,
|
||||
AllowedMethods: []string{"GET", "DELETE", "POST", "PUT"},
|
||||
AllowedHeaders: []string{"Accept", "Authorization", "Content-Type"},
|
||||
})
|
||||
|
||||
handler := c.Handler(r)
|
||||
// var handler http.Handler = r
|
||||
|
||||
handler = handlers.CompressHandler(handler)
|
||||
|
||||
@ -145,6 +158,7 @@ func (s *Server) createHTTPServer() (*http.Server, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
// loggingMiddleware is used for logging public api calls
|
||||
func loggingMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
route := mux.CurrentRoute(r)
|
||||
@ -155,6 +169,18 @@ func loggingMiddleware(next http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// loggingMiddlewarePrivate is used for logging private api calls
|
||||
// from internal services like alert manager
|
||||
func loggingMiddlewarePrivate(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
route := mux.CurrentRoute(r)
|
||||
path, _ := route.GetPathTemplate()
|
||||
startTime := time.Now()
|
||||
next.ServeHTTP(w, r)
|
||||
zap.S().Info(path, "\tprivatePort: true", "\ttimeTaken: ", time.Now().Sub(startTime))
|
||||
})
|
||||
}
|
||||
|
||||
type loggingResponseWriter struct {
|
||||
http.ResponseWriter
|
||||
statusCode int
|
||||
@ -198,61 +224,42 @@ func setTimeoutMiddleware(next http.Handler) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
// initListener initialises listeners of the server
|
||||
func (s *Server) initListener() (cmux.CMux, error) {
|
||||
if s.separatePorts { // use separate ports and listeners each for gRPC and HTTP requests
|
||||
// initListeners initialises listeners of the server
|
||||
func (s *Server) initListeners() error {
|
||||
// listen on public port
|
||||
var err error
|
||||
// s.grpcConn, err = net.Listen("tcp", s.queryOptions.GRPCHostPort)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
publicHostPort := s.serverOptions.HTTPHostPort
|
||||
if publicHostPort == "" {
|
||||
return fmt.Errorf("constants.HTTPHostPort is required")
|
||||
}
|
||||
|
||||
s.httpConn, err = net.Listen("tcp", s.serverOptions.HTTPHostPort)
|
||||
s.httpConn, err = net.Listen("tcp", publicHostPort)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
zap.S().Info("Query server started ...")
|
||||
return nil, nil
|
||||
return err
|
||||
}
|
||||
|
||||
// // old behavior using cmux
|
||||
// conn, err := net.Listen("tcp", s.queryOptions.HostPort)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
// s.conn = conn
|
||||
zap.S().Info(fmt.Sprintf("Query server started listening on %s...", s.serverOptions.HTTPHostPort))
|
||||
|
||||
// var tcpPort int
|
||||
// if port, err := netutils
|
||||
// listen on private port to support internal services
|
||||
privateHostPort := s.serverOptions.PrivateHostPort
|
||||
|
||||
// utils.GetPort(s.conn.Addr()); err == nil {
|
||||
// tcpPort = port
|
||||
// }
|
||||
if privateHostPort == "" {
|
||||
return fmt.Errorf("constants.PrivateHostPort is required")
|
||||
}
|
||||
|
||||
// zap.S().Info(
|
||||
// "Query server started",
|
||||
// zap.Int("port", tcpPort),
|
||||
// zap.String("addr", s.queryOptions.HostPort))
|
||||
|
||||
// // cmux server acts as a reverse-proxy between HTTP and GRPC backends.
|
||||
// cmuxServer := cmux.New(s.conn)
|
||||
|
||||
// s.grpcConn = cmuxServer.MatchWithWriters(
|
||||
// cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc"),
|
||||
// cmux.HTTP2MatchHeaderFieldSendSettings("content-type", "application/grpc+proto"),
|
||||
// )
|
||||
// s.httpConn = cmuxServer.Match(cmux.Any())
|
||||
// s.queryOptions.HTTPHostPort = s.queryOptions.HostPort
|
||||
// s.queryOptions.GRPCHostPort = s.queryOptions.HostPort
|
||||
|
||||
return nil, nil
|
||||
s.privateConn, err = net.Listen("tcp", privateHostPort)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
zap.S().Info(fmt.Sprintf("Query server started listening on private port %s...", s.serverOptions.PrivateHostPort))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Start http, GRPC and cmux servers concurrently
|
||||
// Start listening on http and private http port concurrently
|
||||
func (s *Server) Start() error {
|
||||
|
||||
_, err := s.initListener()
|
||||
err := s.initListeners()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -283,5 +290,25 @@ func (s *Server) Start() error {
|
||||
}
|
||||
}()
|
||||
|
||||
var privatePort int
|
||||
if port, err := utils.GetPort(s.privateConn.Addr()); err == nil {
|
||||
privatePort = port
|
||||
}
|
||||
fmt.Println("starting private http")
|
||||
go func() {
|
||||
zap.S().Info("Starting Private HTTP server", zap.Int("port", privatePort), zap.String("addr", s.serverOptions.PrivateHostPort))
|
||||
|
||||
switch err := s.privateHTTP.Serve(s.privateConn); err {
|
||||
case nil, http.ErrServerClosed, cmux.ErrListenerClosed:
|
||||
// normal exit, nothing to do
|
||||
zap.S().Info("private http server closed")
|
||||
default:
|
||||
zap.S().Error("Could not start private HTTP server", zap.Error(err))
|
||||
}
|
||||
|
||||
s.unavailableChannel <- healthcheck.Unavailable
|
||||
|
||||
}()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
const (
|
||||
HTTPHostPort = "0.0.0.0:8080" // Address to serve http (query service)
|
||||
PrivateHostPort = "0.0.0.0:8085" // Address to server internal services like alert manager
|
||||
DebugHttpPort = "0.0.0.0:6060" // Address to serve http (pprof)
|
||||
)
|
||||
|
||||
|
@ -35,6 +35,7 @@ func main() {
|
||||
|
||||
serverOptions := &app.ServerOptions{
|
||||
HTTPHostPort: constants.HTTPHostPort,
|
||||
PrivateHostPort: constants.PrivateHostPort,
|
||||
}
|
||||
|
||||
// Read the jwt secret key
|
||||
|
@ -23,7 +23,7 @@ services:
|
||||
- query-service
|
||||
restart: on-failure
|
||||
command:
|
||||
- --queryService.url=http://query-service:8080
|
||||
- --queryService.url=http://query-service:8085
|
||||
- --storage.path=/data
|
||||
|
||||
query-service:
|
||||
@ -51,7 +51,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
@ -64,7 +64,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector-metrics:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-metrics-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml
|
||||
|
@ -26,7 +26,7 @@ services:
|
||||
- query-service
|
||||
restart: on-failure
|
||||
command:
|
||||
- --queryService.url=http://query-service:8080
|
||||
- --queryService.url=http://query-service:8085
|
||||
- --storage.path=/data
|
||||
|
||||
# Notes for Maintainers/Contributors who will change Line Numbers of Frontend & Query-Section. Please Update Line Numbers in `./scripts/commentLinesForSetup.sh` & `./CONTRIBUTING.md`
|
||||
@ -56,7 +56,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-config.yaml:/etc/otel-collector-config.yaml
|
||||
@ -69,7 +69,7 @@ services:
|
||||
condition: service_healthy
|
||||
|
||||
otel-collector-metrics:
|
||||
image: signoz/otelcontribcol:0.43.0-0.1
|
||||
image: signoz/otelcontribcol:0.45.1-0.2
|
||||
command: ["--config=/etc/otel-collector-metrics-config.yaml"]
|
||||
volumes:
|
||||
- ./otel-collector-metrics-config.yaml:/etc/otel-collector-metrics-config.yaml
|
||||
|
@ -49,7 +49,7 @@ extensions:
|
||||
health_check: {}
|
||||
zpages: {}
|
||||
exporters:
|
||||
clickhouse:
|
||||
clickhousetraces:
|
||||
datasource: tcp://clickhouse:9000/?database=signoz_traces
|
||||
clickhousemetricswrite:
|
||||
endpoint: tcp://clickhouse:9000/?database=signoz_metrics
|
||||
@ -63,7 +63,7 @@ service:
|
||||
traces:
|
||||
receivers: [jaeger, otlp]
|
||||
processors: [signozspanmetrics/prometheus, batch]
|
||||
exporters: [clickhouse]
|
||||
exporters: [clickhousetraces]
|
||||
metrics:
|
||||
receivers: [otlp, hostmetrics]
|
||||
processors: [batch]
|
||||
|
Loading…
x
Reference in New Issue
Block a user