Secrets in Elasticsearch

Store Elasticsearch credentials as secrets for Elasticsearch destination nodes.

Store Elasticsearch credentials as secrets for Elasticsearch destination nodes.

Elasticsearch Destination

Secrets to create:

Secret NameDescription
es-usernameElasticsearch username
es-passwordElasticsearch password

Elasticsearch Destination Node:

- name: elasticsearch_destination
  type: elasticsearch_output
  endpoint: https://elasticsearch.example.com:9200
  index: logs
  username: '{{ SECRET es-username }}'
  password: '{{ SECRET es-password }}'

Elasticsearch with API Key

If using API key authentication instead of basic auth, store the API key as a secret.

Secret to create:

Secret NameDescription
es-api-keyElasticsearch API key

Elasticsearch with API Key:

- name: elasticsearch_destination
  type: elasticsearch_output
  endpoint: https://elasticsearch.example.com:9200
  index: logs
  api_key: '{{ SECRET es-api-key }}'

Multiple Elasticsearch Clusters

If you send data to multiple Elasticsearch clusters, create separate secrets for each.

Secrets to create:

Secret NameDescription
es-prod-usernameProduction Elasticsearch username
es-prod-passwordProduction Elasticsearch password
es-staging-usernameStaging Elasticsearch username
es-staging-passwordStaging Elasticsearch password

Multiple Elasticsearch Destinations:

- name: elasticsearch_prod
  type: elasticsearch_output
  endpoint: https://es-prod.example.com:9200
  index: prod-logs
  username: '{{ SECRET es-prod-username }}'
  password: '{{ SECRET es-prod-password }}'

- name: elasticsearch_staging
  type: elasticsearch_output
  endpoint: https://es-staging.example.com:9200
  index: staging-logs
  username: '{{ SECRET es-staging-username }}'
  password: '{{ SECRET es-staging-password }}'

See Also