Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect AWS region from instance metadata #7

Closed
mikelorant opened this issue Oct 5, 2021 · 6 comments · Fixed by #12
Closed

Detect AWS region from instance metadata #7

mikelorant opened this issue Oct 5, 2021 · 6 comments · Fixed by #12

Comments

@mikelorant
Copy link

When starting discovery, receive the following error:

operation error Kafka: ListClusters, failed to resolve service endpoint, an AWS region is required, but was not found

This can be resolved by setting the AWS_REGION environmental variable but this can also be determined from the instance metadata so it would not be necessary to configure anything (as long as the MSK clusters in the same region).

@joshm91
Copy link
Contributor

joshm91 commented Oct 5, 2021

Hey Mike,

Thanks for this! I'm guessing this was running the binary directly on an EC2 instance? It's not something that was caught since we generally only use it in the Docker image on an EKS cluster which tends to set the required environment variables.

It looks like an easy fix so let me just test it some more and I'll push the new version.

@mikelorant
Copy link
Author

I am running it in a pod within our Kops built Kubernetes cluster.

It was just the sidecar container of the Prometheus Helm chart. Nothing special at all.

@joshm91
Copy link
Contributor

joshm91 commented Oct 5, 2021

Got it, thanks!

When you get a chance, can you try the Docker image: statsbomb/prometheus-msk-discovery:ec2region and let me know if it works as expected.

@imriz
Copy link
Contributor

imriz commented Dec 2, 2021

I just encountered the same issue, and statsbomb/prometheus-msk-discovery:ec2region solved it for me.
As a suggestion - maybe add an option to explicitly set it via CLI (although I assume the standard AWS env var will also work?).
Another one, more important, is to allow passing a list of regions, to scan them all.

@joshm91
Copy link
Contributor

joshm91 commented Dec 2, 2021

@imriz Thanks for confirming! I'll create a proper release with the fix today.

As for the list of regions I've created a dedicated feature request for it (#10) but I suspect it'd require a bit of rewrite to implement so I can't promise it'll be done any time soon.

Allowing specifying a single region as a parameter shouldn't be too difficult (#11) but in the meantime I'd imagine you could just set the AWS_REGION environment variable to the desired region and things should work.

@joshm91
Copy link
Contributor

joshm91 commented Dec 2, 2021

@mikelorant @imriz The image statsbomb/prometheus-msk-discovery:0.3.0 now contains the EC2 IMDS fallback as well as the ability to specify a region with the -region flag.

Let me know if you have any problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants