From d9de2b294bfeacd729214cf007e5b383e0d7e748 Mon Sep 17 00:00:00 2001 From: Ricardo F <112904881+rfmoz@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:08:09 +0200 Subject: [PATCH] close #7924 - Update usage and behaviour of tags in http input (#1195) * close #7924 - Update usage and behaviour of tags in http input Signed-off-by: Ricardo F * close #7924 - Split lines to allow easier review Signed-off-by: Ricardo F --------- Signed-off-by: Ricardo F Co-authored-by: Ricardo F --- pipeline/inputs/http.md | 69 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/pipeline/inputs/http.md b/pipeline/inputs/http.md index 10f842c01..aead92d9d 100644 --- a/pipeline/inputs/http.md +++ b/pipeline/inputs/http.md @@ -28,7 +28,74 @@ The http input plugin allows Fluent Bit to open up an HTTP port that you can the #### How to set tag -The tag for the HTTP input plugin is set by adding the tag to the end of the request URL. This tag is then used to route the event through the system. For example, in the following curl message below the tag set is `app.log`**. **If you do not set the tag `http.0` is automatically used. If you have multiple HTTP inputs then they will follow a pattern of `http.N` where N is an integer representing the input. +The tag for the HTTP input plugin is set by adding the tag to the end of the request URL. This tag is then used to route the event through the system. +For example, in the following curl message below the tag set is `app.log**. **` because the end end path is `/app_log`: + +### Curl request + +``` +curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888/app.log +``` + +### Configuration File + +``` +[INPUT] + name http + listen 0.0.0.0 + port 8888 + +[OUTPUT] + name stdout + match app.log +``` + +If you do not set the tag `http.0` is automatically used. If you have multiple HTTP inputs then they will follow a pattern of `http.N` where N is an integer representing the input. + +### Curl request + +``` +curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888 +``` + +### Configuration File + +``` +[INPUT] + name http + listen 0.0.0.0 + port 8888 + +[OUTPUT] + name stdout + match http.0 +``` + + +#### How to set tag_key + +The tag_key configuration option allows to specify the key name that will be used to overwrite a tag. The tag's value will be replaced with the value associated with the specified key. For example, setting tag_key to "custom_tag" and the log event contains a json field with the key "custom_tag" Fluent Bit will use the value of that field as the new tag for routing the event through the system. + +### Curl request + +``` +curl -d '{"key1":"value1","key2":"value2"}' -XPOST -H "content-type: application/json" http://localhost:8888/app.log +``` + +### Configuration File + +``` +[INPUT] + name http + listen 0.0.0.0 + port 8888 + tag_key key1 + +[OUTPUT] + name stdout + match value1 +``` + #### How to set multiple custom HTTP header on success