README
¶
HTTP Listener v2 Input Plugin
HTTP Listener v2 is a service input plugin that listens for metrics sent via HTTP. Metrics may be sent in any supported data format.
Note: The plugin previously known as http_listener
has been renamed
influxdb_listener
. If you would like Telegraf to act as a proxy/relay for
InfluxDB it is recommended to use influxdb_listener
.
Configuration:
This is a sample configuration for the plugin.
[[inputs.http_listener_v2]]
## Address and port to host HTTP listener on
service_address = ":8080"
## Path to listen to.
# path = "/telegraf"
## HTTP methods to accept.
# methods = ["POST", "PUT"]
## maximum duration before timing out read of the request
# read_timeout = "10s"
## maximum duration before timing out write of the response
# write_timeout = "10s"
## Maximum allowed http request body size in bytes.
## 0 means to use the default of 524,288,000 bytes (500 mebibytes)
# max_body_size = "500MB"
## Set one or more allowed client CA certificate file names to
## enable mutually authenticated TLS connections
# tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
## Add service certificate and key
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Optional username and password to accept for HTTP basic authentication.
## You probably want to make sure you have TLS configured above for this.
# basic_username = "foobar"
# basic_password = "barfoo"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "influx"
Metrics:
Metrics are created from the request body and are dependant on the value of data_format
.
Troubleshooting:
Send Line Protocol
curl -i -XPOST 'http://localhost:8080/telegraf' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
Send JSON
curl -i -XPOST 'http://localhost:8080/telegraf' --data-binary '{"value1": 42, "value2": 42}'
Documentation
¶
Index ¶
- type HTTPListenerV2
- func (h *HTTPListenerV2) AuthenticateIfSet(handler http.HandlerFunc, res http.ResponseWriter, req *http.Request)
- func (h *HTTPListenerV2) Description() string
- func (h *HTTPListenerV2) Gather(_ telegraf.Accumulator) error
- func (h *HTTPListenerV2) SampleConfig() string
- func (h *HTTPListenerV2) ServeHTTP(res http.ResponseWriter, req *http.Request)
- func (h *HTTPListenerV2) SetParser(parser parsers.Parser)
- func (h *HTTPListenerV2) Start(acc telegraf.Accumulator) error
- func (h *HTTPListenerV2) Stop()
- type TimeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPListenerV2 ¶
type HTTPListenerV2 struct { ServiceAddress string Path string Methods []string ReadTimeout internal.Duration WriteTimeout internal.Duration MaxBodySize internal.Size Port int tlsint.ServerConfig BasicUsername string BasicPassword string TimeFunc parsers.Parser // contains filtered or unexported fields }
func (*HTTPListenerV2) AuthenticateIfSet ¶
func (h *HTTPListenerV2) AuthenticateIfSet(handler http.HandlerFunc, res http.ResponseWriter, req *http.Request)
func (*HTTPListenerV2) Description ¶
func (h *HTTPListenerV2) Description() string
func (*HTTPListenerV2) Gather ¶
func (h *HTTPListenerV2) Gather(_ telegraf.Accumulator) error
func (*HTTPListenerV2) SampleConfig ¶
func (h *HTTPListenerV2) SampleConfig() string
func (*HTTPListenerV2) ServeHTTP ¶
func (h *HTTPListenerV2) ServeHTTP(res http.ResponseWriter, req *http.Request)
func (*HTTPListenerV2) SetParser ¶
func (h *HTTPListenerV2) SetParser(parser parsers.Parser)
func (*HTTPListenerV2) Start ¶
func (h *HTTPListenerV2) Start(acc telegraf.Accumulator) error
Start starts the http listener service.
Click to show internal directories.
Click to hide internal directories.