influxdata / kapacitor

Open source framework for processing, monitoring, and alerting on time series data
MIT License
2.32k stars 493 forks source link

logging API returns logfmt format regardless of header #2015

Open sprichar opened 6 years ago

sprichar commented 6 years ago

when executing GET /kapacitor/v1preview/logs Content-Type: application/json

I always get logfmt format back...

root@devdatacenter-kapacitor-0:/# curl --header "Content-Type: application/json" localhost:9092/kapacitor/v1preview/logs ts=2018-08-08T20:48:19.626Z lvl=info msg="created log session" service=sessions id=cd1e7a68-a6d0-4a5f-9a0d-d7842e2ecca0 content-type=application/logfmt ...

2018/08/08 19:57:47 Using configuration at: /etc/kapacitor/kapacitor.conf ts=2018-08-08T19:57:47.978Z lvl=info msg="kapacitor starting" service=run version=1.5.0 branch=HEAD commit=ee0d8bc17a01a3321d7d44eb5ee8e1156c3d5ec6 ts=2018-08-08T19:57:47.978Z lvl=info msg="go version" service=run version=go1.10.2

dp1140a commented 6 years ago

This might be a docs error in the header name. In the code it looks like it might be looking for the "Accept" header. try setting that to application/json

acceptedContentType := r.Header.Get("Accept")
    var contentType string
    switch acceptedContentType {
    case "application/json":
        contentType = acceptedContentType
    default:
        contentType = "application/logfmt"
    }

https://github.com/influxdata/kapacitor/blob/268f3b0be23d620a9459dd213afc75c87e1f9306/services/diagnostic/api.go#L105

scrichar commented 6 years ago

thanks