How to create API key with built-in role ? Filebeat to Elastic configuration

Hello all !

I am currently following the nginx filebeat integration from Filebeat to Elastic and I want to use api_key instead of username/password to authenticate to my Elastic instance and setup the filebeat module.

Based on that Grant privileges and roles needed for setup doc, I need to give some priviledge to the user or api_key, but also assign two built-in role kibana_admin and ingest_admin.

I have read the Grant access using API keys but I do not know how to add built-in role to the api_token I am creating... is it possible ?

For now am I using this block to create my API key :

POST /_security/api_key
  "name": "filebeat_host001", 
  "role_descriptors": {
    "filebeat_setup": { 
      "cluster": ["monitor", "manage_ilm"],
      "index": [
          "names": ["filebeat-*"],
          "privileges": ["manage"]

As expected I have error message like this when runninng filebeat with the created API key :
Error importing directory /opt/filebeat-8.10.3-linux-x86_64/kibana: failed to import Kibana index pattern: 1 error: error loading index pattern: returned 403 to import file: Unable to bulk_create index-pattern.

Thanks for you help !

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.