diff --git a/src/pkg/aop/logger.go b/src/pkg/aop/logger.go index 0af299f8..8457ed46 100644 --- a/src/pkg/aop/logger.go +++ b/src/pkg/aop/logger.go @@ -276,7 +276,7 @@ func LoggerWithConfig(conf LoggerConfig) gin.HandlerFunc { param.Path = path // fmt.Fprint(out, formatter(param)) - logger.Debug(formatter(param)) + logger.Info(formatter(param)) // if c.Request.Method != "GET" { // logger.Debug(readBody(rdr1)) diff --git a/src/server/router/router.go b/src/server/router/router.go index 92c795f2..41937579 100644 --- a/src/server/router/router.go +++ b/src/server/router/router.go @@ -67,6 +67,10 @@ func configRoute(r *gin.Engine, version string) { // use apiKey not basic auth r.POST("/datadog/api/v1/series", datadogSeries) + r.POST("/datadog/api/v1/check_run", datadogCheckRun) + r.GET("/datadog/api/v1/validate", datadogValidate) + r.POST("/datadog/api/v1/metadata", datadogMetadata) + r.POST("/datadog/intake/", datadogIntake) if len(config.C.BasicAuth) > 0 { auth := gin.BasicAuth(config.C.BasicAuth) diff --git a/src/server/router/router_datadog.go b/src/server/router/router_datadog.go index 4c75e50f..4e897a89 100644 --- a/src/server/router/router_datadog.go +++ b/src/server/router/router_datadog.go @@ -139,6 +139,52 @@ func (m *DatadogMetric) ToProm() (*prompb.TimeSeries, string, error) { return pt, ident, nil } +func datadogCheckRun(c *gin.Context) { + c.String(200, "not implemented") +} + +func datadogValidate(c *gin.Context) { + c.String(200, "not implemented") +} + +func datadogIntake(c *gin.Context) { + c.String(200, "not implemented") +} + +func datadogMetadata(c *gin.Context) { + // body, err := readDatadogBody(c) + // fmt.Println("metadata:", string(body), err) + c.String(200, "not implemented") +} + +func readDatadogBody(c *gin.Context) ([]byte, error) { + var bs []byte + var err error + + enc := c.GetHeader("Content-Encoding") + + if enc == "gzip" { + r, e := gzip.NewReader(c.Request.Body) + if e != nil { + return nil, e + } + defer r.Close() + bs, err = ioutil.ReadAll(r) + } else if enc == "deflate" { + r, e := zlib.NewReader(c.Request.Body) + if e != nil { + return nil, e + } + defer r.Close() + bs, err = ioutil.ReadAll(r) + } else { + defer c.Request.Body.Close() + bs, err = ioutil.ReadAll(c.Request.Body) + } + + return bs, err +} + func datadogSeries(c *gin.Context) { apiKey, has := c.GetQuery("api_key") if !has { @@ -161,32 +207,7 @@ func datadogSeries(c *gin.Context) { } } - var bs []byte - var err error - - enc := c.GetHeader("Content-Encoding") - - if enc == "gzip" { - r, err := gzip.NewReader(c.Request.Body) - if err != nil { - c.String(400, err.Error()) - return - } - defer r.Close() - bs, err = ioutil.ReadAll(r) - } else if enc == "deflate" { - r, err := zlib.NewReader(c.Request.Body) - if err != nil { - c.String(400, err.Error()) - return - } - defer r.Close() - bs, err = ioutil.ReadAll(r) - } else { - defer c.Request.Body.Close() - bs, err = ioutil.ReadAll(c.Request.Body) - } - + bs, err := readDatadogBody(c) if err != nil { c.String(400, err.Error()) return