Comments (5)
😅 The logic is
- get wifi login https://github.com/aws/amazon-cloudwatch-agent/blob/master/translator/util/ec2util/ec2util.go#L57-L57
- use it as hostname https://github.com/aws/amazon-cloudwatch-agent/blob/master/translator/translate/util/placeholderUtil.go#L52-L52
But I think it won't get triggered if the agent is configured as onPrem using -m onPremise
I think you are using default, which is auto detection without validation
func initEC2UtilSingleton() (newInstance *ec2Util) {
newInstance = &ec2Util{Region: "", PrivateIP: ""}
if context.CurrentContext().Mode() == config.ModeOnPrem {
return
}
if info, e := md.GetMetadata("hostname"); e == nil {
newInstance.Hostname = info
} else {
log.Println("E! getting hostname from EC2 metadata fail: ", e)
}
}
-m: mode
ec2: indicate this is on ec2 host.
onPremise: indicate this is on onPremise host.
auto: use ec2 metadata to determine the environment, may not be accurate if ec2 metadata is not available for some reason on EC2.
There are some inconsistencies in our logic, the credential has fall backed to static creds instead of using ec2 instance profile, while the hostname logic took wifi logic page as valid ec2 metadata api response. I think we can add a logic to avoid case like this, though the best approach for your use case should be specifying onPremise
btw: in aws go sdk, the ec2metadata API just copy the content without decoding
from amazon-cloudwatch-agent.
Ahh, I can definitely move forward with the -m option. Thank you!!
from amazon-cloudwatch-agent.
So turns out I was already using the -m onPremise option :( So I am going to re-open this ticket.
Perhaps potential solution now is to verify -m onPremise uses os.hostname by default?
from amazon-cloudwatch-agent.
I'm assuming that the current logic relies on the request to the metadata endpoint to fail as the decision to use alternative means to lookup the hostname. This should be pretty easy to replicate by spoofing the response from the metadata endpoint ip to verify this behavior.
from amazon-cloudwatch-agent.
@farrantch Have you tried using the {local_hostname}
placeholder instead of {hostname}
?
I didn't know about this until just now as I was looking at the code in ./translator/translate/util/placeholderUtil.go
func getHostName() string {
if hostname, err := os.Hostname(); err == nil {
return hostname
} else {
log.Println("E! getHostName: ", err)
return unknownHostname
}
}
from amazon-cloudwatch-agent.
Related Issues (20)
- amazon-cloudwatch-observability fails with open /root/.aws/credentials ignoring the IRSA credentials HOT 12
- Log agent not running as root sometimes fails to tail log files HOT 3
- Example for append_dimensions using a value that depends on Amazon EC2 metadata HOT 2
- Container is stopped. On-premise setup. HOT 3
- X-Ray: how to set index_all_attributes (or provide a list of attributes to index)? HOT 2
- [k8s / EKS] Support for Filtering Metrics by Namespace/Pod Name in CloudWatch Agent HOT 3
- https://github.com/aws/amazon-cloudwatch-agent/releases shows v1.300034.0 but that is not current HOT 1
- CloudWatch metrics collected from prometheus , contains undesired dimensions HOT 2
- Undesired metrics added HOT 2
- [K8E mode] CloudWatch Agent shutting down when configured to collect container insights metric on EC2 K8s setup HOT 1
- I wish fetch-config would not delete the .json config file HOT 5
- Publish a JSON schema of the config HOT 7
- Add KMS Key to Cloudwatch Log Group HOT 2
- Support Credentials from IAM Roles Anywhere HOT 3
- Agent fails to detect EKS cluster created in Access Entries only authentication mode HOT 4
- Append dimensions ssm managed instance id support
- Static append_dimensions value on prem results in no metrics being published HOT 3
- GPG Verification Failure for CloudWatch Agent on RHEL 8 HOT 2
- Cloudwatch Agent metrics endpoint unavailable HOT 1
- Parameterize `start-amazon-cloudwatch-agent` for portability. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-cloudwatch-agent.