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)
- How should the CloudWatch agent be configured with credentials when it sends logs to CloudWatch in other regions? HOT 1
- Failed to start CloudWatch agent on ubuntu22.04 HOT 2
- Set sampling rate in CloudWatch agent HOT 2
- local script failed to redirect to cw log even when it's created HOT 1
- Conflict error when installing amazon-cloudwatch-agent in EC2 user data HOT 4
- CW Agent not recognizing enhanced_container_insights=true using EKS/ConfigMap HOT 2
- Batch Parsing EMF Logs with Large Numeric Array Targets (>100 Members) HOT 1
- amazon/cloudwatch-agent:1.0.3 doesn't start on Fargate HOT 4
- aggregation_dimensions does not work with statsd
- The CloudWatch Agent requires additional configuration to use IAM Roles for Service Accounts (IRSA) or Pod Identity HOT 2
- Unable to reload agent with error message unable to address what is wrong HOT 1
- Rotate amazon-cloudwatch-agent.log HOT 2
- XRay traces sent by cloudwatch-agent are missing cloudwatch_logs data HOT 2
- cannot get pod from kubelet, err: call to /pods endpoint failed: HOT 2
- 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 1
- Container is stopped. On-premise setup. HOT 2
- X-Ray: how to set index_all_attributes (or provide a list of attributes to index)? HOT 2
- Agent starts running and then exits with Cannot translate JSON, ERROR is exit status 1 HOT 4
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.