Hello,
I have setup filebeat in kubernetes clusters, that is collecting logs from all containers with a specific annotation. The annotation its looking for is kubernetes.labels.apps
Elastic search cluster is running in AWS, which am using AWS elastic search resource with 3 nodes.
The cluster is working well now and the index name is filebeat-{{ .Values.elasticsearch.indexSuffix }}-%{+yyyy.MM.dd}
The relevant config looks like
output.elasticsearch:
  hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
  protocol: "https"
  headers: ["Content-Type: application/json"]
  index: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}-%{[data.kubernetes.labels.app]}-%{+yyyy.MM.dd}'
  ssl.verification_mode: 'none'
logging:
  level: info
setup:
  kibana:
    host: '${ELASTICSEARCH_HOST:elasticsearch}/_plugin/kibana/'
  template:
    name: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}'
    pattern: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}*'
    settings:
      index:
        number_of_shards: 3
        number_of_replicas: 3
I am thinking to have an index per application or per name space. Can anyone help me how to achieve it.
I tried to have an index per application by changing the above config to
    output.elasticsearch:
      hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
      protocol: "https"
      headers: ["Content-Type: application/json"]
      index: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}-%{[data.kubernetes.labels.app]}-%{+yyyy.MM.dd}'
      ssl.verification_mode: 'none'
    logging:
      level: info
    setup:
      kibana:
        host: '${ELASTICSEARCH_HOST:elasticsearch}/_plugin/kibana/'
      template:
        name: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}-%{[data.kubernetes.labels.app]}'
        pattern: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}-%{[data.kubernetes.labels.app]}*'
But then nothing is getting published and from logs I can see below error
2019-08-07T14:20:39.627Z	ERROR	pipeline/output.go:100	Failed to connect to backoff(elasticsearch(https://k8s-logs-elk-qa.private:443)): Connection marked as failed because the onConnect callback failed: Error loading Elasticsearch template: error creating template instance: key not found
Then I tried with this config
    setup:
      kibana:
        host: '${ELASTICSEARCH_HOST:elasticsearch}/_plugin/kibana/'
      template:
        name: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}'
        pattern: 'filebeat-{{ .Values.elasticsearch.indexSuffix }}*'
        settings:
          index:
            number_of_shards: 3
            number_of_replicas: 3
and getting error like
2019-08-07T10:54:50.971Z	DEBUG	[elasticsearch]	elasticsearch/client.go:731	HEAD https://k8s-logs-elk-qa.private:443/_template/filebeat-qa  <nil>
2019-08-07T10:54:50.975Z	INFO	template/load.go:129	Template already exists and will not be overwritten.
2019-08-07T10:54:50.975Z	INFO	pipeline/output.go:105	Connection to backoff(elasticsearch(https://k8s-logs-elk-qa.private:443)) established
2019-08-07T10:54:50.975Z	INFO	[publish]	pipeline/retry.go:189	retryer: send unwait-signal to consumer
2019-08-07T10:54:50.975Z	INFO	[publish]	pipeline/retry.go:191	  done
2019-08-07T10:54:50.982Z	DEBUG	[elasticsearch]	elasticsearch/client.go:321	PublishEvents: 50 events have been published to elasticsearch in 7.165086ms.
2019-08-07T10:54:50.982Z	DEBUG	[elasticsearch]	elasticsearch/client.go:526	Bulk item insert failed (i=0, status=500): {"type":"string_index_out_of_bounds_exception","reason":"String index out of range: 0"}
2019-08-07T10:54:50.982Z	DEBUG	[elasticsearch]	elasticsearch/client.go:526	Bulk item insert failed (i=1, status=500): {"type":"string_index_out_of_bounds_exception","reason":"String index out of range: 0"}
2019-08-07T10:54:50.982Z	DEBUG	[elasticsearch]	elasticsearch/client.go:526	Bulk item insert failed (i=2, status=500): {"type":"string_index_out_of_bounds_exception","reason":"String index out of range: 0"}
Can someone please help me ?
Thanks
  but, apparently -  as for me - the condition  play here: 1) 'when' 'and' (that is, two values must match (  app-service1& default)