monstache icon indicating copy to clipboard operation
monstache copied to clipboard

Elastic APIKey authentication

Open dwalker-va opened this issue 3 years ago • 6 comments

Hi, I have a team that would like to connect to Elastic using Monstache. As the administrator I do not have PKI enabled on the cluster and we use API Keys instead. Is there a reason that Monstache does not support API Key authentication?

My team would be willing to help add the option if it sounds like a good idea.

dwalker-va avatar Dec 10 '21 15:12 dwalker-va

Hi @dwalker-va if your team could submit a PR I'd be happy to review and merge it.

I think it would just be a matter of a new config option with support for env var to pass in the key. And then if that is set, wrap the transport to set the Authorization header.

rwynn avatar Dec 11 '21 04:12 rwynn

👍 API key support would be great, I know internally we've been talking about moving in that direction.

patrickserrano avatar Jan 04 '22 14:01 patrickserrano

Hi! First of all, thanks for creating this software. I'm trying to connect using the latest version of monstache built from 905547a and my API key but monstache fails, reporting

Unable to create Elasticsearch client: elastic: Error 401 (Unauthorized)

The -verbose option does not give further details.

I tested my API key using curl -X GET -H "Authorization: ApiKey xxxxxxxxxxxxxxxxxxxxxxxx" https://MY_ELASTIC_SEARCH_URL which correctly reports

{
  "name" : "node-2",
  "cluster_name" : "MY_CLUSTER_NAME",
  [...]
  "tagline" : "You Know, for Search"
}

Can I help resolving this issue? I have never used Go but I'd like to help.

andreadistefano avatar Feb 25 '22 09:02 andreadistefano

Yeah, any help would be really appreciated. Let me know if you need any help getting started.
After installing go you should just be able to run monstache with go run monstache.go -f myconfig.toml.

rwynn avatar Feb 25 '22 16:02 rwynn

@andreadistefano I did notice and correct one issue with reading the api key from the toml config file. Please let me know if that helps.

rwynn avatar Feb 28 '22 02:02 rwynn

Sorry for not getting back to you over the weekend, I can confirm that on commit 936590a the authentication works correctly for me.
Thank you so much!

andreadistefano avatar Feb 28 '22 08:02 andreadistefano