Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify an index #421

Closed
andrewmyhre opened this issue Nov 7, 2017 · 14 comments
Closed

Ability to specify an index #421

andrewmyhre opened this issue Nov 7, 2017 · 14 comments
Assignees

Comments

@andrewmyhre
Copy link

In a kubernetes cluster it would be useful if fluent-bit were to specify an index with log requests. In a fluentd configuration we would have the following:

<match **>
    type elasticsearch_dynamic
    log_level info
    include_tag_key true
    host elasticsearch-logging
    port 9200
    logstash_format true
    logstash_prefix logstash-${record['kubernetes']['namespace_name']}
    reload_connections false
    # Set the chunk limit the same as for fluentd-gcp.
    buffer_chunk_limit 2M

I'm not sure but the the appropriate configuration setting might actually be target_index rather than logstash_prefix.
The desired end result is that logs are shipped with _index including the name of the kubernetes namespace.
It would be great if fluent-bit allowed configuring this.

@edsiper edsiper self-assigned this Nov 7, 2017
@mvladev
Copy link

mvladev commented Feb 12, 2018

I think it's the same enhancement as in #242, but for host field.

@brycefisher
Copy link

I would also find this feature extremely useful!

@max-lobur
Copy link

max-lobur commented Nov 16, 2018

Can fluent-bit even do logstash_prefix ${record['kubernetes']['namespace_name']}?
I can't find.
I would be very happy If I can set logstash_prefix to k8s namespace at least, I can then set index pattern to <namespace>-* and live with prefix as usually

@kfox1111
Copy link

kfox1111 commented Dec 4, 2018

Not quite the same thing, but might work...
Set fluent-bit to point at a fluentd cluster in k8s. Then it looks like the fluentd es plugin might be able to specify an index based on tag:
https://docs.fluentd.org/v1.0/articles/out_elasticsearch

This also separates your log shipping from your log processing so you can scale each out separately.

(If you try this soon, please let me know if it works for you. I haven't tried it yet and am curious if it works)

@zeph
Copy link

zeph commented May 6, 2019

👍

@dhananjaysathe
Copy link
Contributor

Ok this feature looks like it landed in master when i look at the code https://github.com/fluent/fluent-bit/blob/master/plugins/out_es/es.c#L265
Here is the commit / MR : 036c839#diff-197d21cf7c333bb3fc476eeb1e5a7f83

@anand-nair
Copy link

Hi guys,
Checking if this is possible in fluent-bit. Looking for creating indexes in Elasticsearch for each namespace in Kubernetes similar to elasticsearch_dynamic.
Tx

@edsiper
Copy link
Member

edsiper commented Jan 25, 2021

Elasticsearch output plugin has been updated for logstash_prefix_key option. Changes:

    out_es: add support for record accessor on 'logstash_prefix_key' (#1670)
    
    The following patch adds 'record accessor' support for the
    'logstash_prefix_key' configuration property. This enable to have
    custom indices based on nested fields if required, e.g;
    
     {"key1": 1234, "kubernetes": {"labels: {"app": "prod"}}}
    
    You can configure a logstash prefix as follows:
    
     [OUTPUT]
         name                 es
         match                *
         logstash_format      on
         logstash_prefix_key  $kubernetes['labels']['app']
    
    The final index for the record above and the proposed config will generate:
    
     prod-2021.01.24

@edsiper edsiper added the fixed label Jan 25, 2021
@edsiper edsiper closed this as completed Jan 25, 2021
@offero
Copy link

offero commented Jan 26, 2021

@edsiper What version?

@edsiper
Copy link
Member

edsiper commented Jan 26, 2021

It will be part of Fluent Bit v1.7 release (1 or 2 weeks from now)

@64bit
Copy link

64bit commented Jun 4, 2021

It seems to be not working on fluentbit v1.7.7. Is this feature actually relased?

The documentation of v1.7 also suggest its not.
Screen Shot 2021-06-03 at 8 31 33 PM

How do we make it work as originally posted in description and based on last comment something like logstash_prefix logstash-$kubernetes['namespace_name']} ?

thank you.

@qmonitoring
Copy link

It seems to be not working on fluentbit v1.7.7. Is this feature actually relased?

The documentation of v1.7 also suggest its not.
Screen Shot 2021-06-03 at 8 31 33 PM

How do we make it work as originally posted in description and based on last comment something like logstash_prefix logstash-$kubernetes['namespace_name']} ?

thank you.

Please see Make Logstash_Prefix_Key more dynamic #3624

I hope that this functionality will be implemented in the near future.

@ckgmg
Copy link

ckgmg commented Nov 30, 2021

with fluent-bit 1.8

Logstash_Prefix_Key $kubernetes['namespace_name']

Using the above configuration, in the es can be normal index according to the namespace

@XI3423-aarora
Copy link

shall we have any way to separate logs b/w indexes without doing any change in fluentbit:-configmap(input)??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests