Grant access using API keys
editGrant access using API keys
editInstead of using usernames and passwords, you can use API keys to grant
access to Elasticsearch resources. You can set API keys to expire at a certain time,
and you can explicitly invalidate them. Any user with the manage_api_key
or manage_own_api_key
cluster privilege can create API keys.
Filebeat instances typically send both collected data and monitoring information to Elasticsearch. If you are sending both to the same cluster, you can use the same API key. For different clusters, you need to use an API key per cluster.
For security reasons, we recommend using a unique API key per Filebeat instance. You can create as many API keys per user as necessary.
Create an API key for publishing
editTo create an API key to use for writing data to Elasticsearch, use the Create API key API, for example:
POST /_security/api_key { "name": "filebeat_host001", "role_descriptors": { "filebeat_writer": { "cluster": ["monitor", "read_ilm"], "index": [ { "names": ["filebeat-*"], "privileges": ["view_index_metadata", "create_doc"] } ] } } }
Name of the API key |
|
Granted privileges, see Grant users access to secured resources |
The return value will look something like this:
You can now use this API key in your filebeat.yml
configuration file like this:
Format is |
Create an API key for monitoring
editTo create an API key to use for sending monitoring data to Elasticsearch, use the Create API key API, for example:
POST /_security/api_key { "name": "filebeat_host001", "role_descriptors": { "filebeat_monitoring": { "cluster": ["monitor"], "index": [ { "names": [".monitoring-beats-*"], "privileges": ["create_index", "create"] } ] } } }
Name of the API key |
|
Granted privileges, see Grant users access to secured resources |
The return value will look something like this:
You can now use this API key in your filebeat.yml
configuration file like this:
Format is |
Learn more about API keys
editSee the Elasticsearch API key documentation for more information: