Documentation
¶
Index ¶
- Constants
- func BuildListEntitiesForMetricRequest(body []byte, region string) (*http.Request, error)
- func CopyFile(pathIn string, pathOut string)
- func CreateWindowsEvent(eventLogName string, eventLogLevel string, eventID string, msg string) error
- func DeleteFile(filePathAbsolute string) error
- func DownloadFromS3(bucket string, key string, destPath string) error
- func GenerateLogConfig(numberMonitoredLogs int, filePath string) error
- func GenerateLogs(configFilePath string, duration time.Duration, sendingInterval time.Duration, ...) error
- func GenerateWindowsEvents(validationLog []models.LogValidation) error
- func GetAnyEBSVolumeID() (string, error)
- func GetAnyInstanceStoreSerialID() (string, error)
- func GetLogFilePaths(configPath string) ([]string, error)
- func InstallAgent(installerFilePath string) error
- func MkdirAll(path string) error
- func ReadAgentLogfile(logfile string) string
- func RecreateAgentLogfile(logfile string)
- func ReplaceLocalStackHostName(pathIn string)
- func ReplacePlaceholder(filePath, placeholder, value string) error
- func ReplacePlaceholders(filePath string, placeholders map[string]string) error
- func RunAsyncCommand(cmd string) error
- func RunCommand(cmd string) (string, error)
- func RunCommands(commands []string) error
- func RunShellScript(path string, args ...string) (string, error)
- func SELinuxEnforced() (bool, error)
- func SendAppSignalMetrics(duration time.Duration) error
- func SendAppSignalsTraceMetrics(duration time.Duration) error
- func SendCollectDMetrics(metricPerInterval int, sendingInterval, duration time.Duration) error
- func SendEMFMetrics(metricPerInterval int, metricLogGroup, metricNamespace string, ...) error
- func SendPrometheusMetrics(config PrometheusConfig, agentCollectionDuration time.Duration) error
- func SendStatsdMetrics(metricPerInterval int, metricDimension []string, ...) error
- func StartAgent(configOutputPath string, fatalOnFailure bool, ssm bool) error
- func StartAgentWithCommand(configOutputPath string, fatalOnFailure bool, ssm bool, ...) error
- func StartLogWrite(configFilePath string, duration time.Duration, sendingInterval time.Duration, ...) error
- func StartSendingMetrics(receiver string, duration, sendingInterval time.Duration, ...) (err error)
- func StopAgent()
- func TouchFile(filePathAbsolute string) error
- func UninstallAgent(pm PackageManager) error
- func WriteFile(filePath string, content string) error
- type PackageManager
- type PrometheusConfig
Constants ¶
const ( CatCommand = "cat " AppOwnerCommand = "ps -u -p " Namespace = "CWAgent" Host = "host" InstallAgentVersionPath = "/opt/aws/amazon-cloudwatch-agent/bin/CWAGENT_VERSION" )
const ( ConfigOutputPath = "/opt/aws/amazon-cloudwatch-agent/bin/config.json" AgentLogFile = "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log" AgentCommonConfigFile = "/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml" )
const MetricEndpoint = "4316/v1/metrics"
const SleepDuration = 5 * time.Second
const TMPAGENTPATH = "/tmp/agent_config.json"
const TracesEndpoint = "4316/v1/traces"
Variables ¶
This section is empty.
Functions ¶
func BuildListEntitiesForMetricRequest ¶
This function builds and signs an ListEntitiesForMetric call, essentially trying to replicate this curl command:
curl -i -X POST monitoring.us-west-2.amazonaws.com -H 'Content-Type: application/json' \
-H 'Content-Encoding: amz-1.0' \
--user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \
-H "x-amz-security-token: $AWS_SESSION_TOKEN" \
--aws-sigv4 "aws:amz:us-west-2:monitoring" \
-H 'X-Amz-Target: com.amazonaws.cloudwatch.v2013_01_16.CloudWatchVersion20130116.ListEntitiesForMetric' \
-d '{
// sample request body:
"Namespace": "CWAgent",
"MetricName": "cpu_usage_idle",
"Dimensions": [{"Name": "InstanceId", "Value": "i-0123456789012"}, { "Name": "cpu", "Value": "cpu-total"}]
}'
func CreateWindowsEvent ¶
func DeleteFile ¶
func GenerateLogConfig ¶
GenerateLogConfig takes the number of logs to be monitored and applies it to the supplied config, It writes logs to be monitored of the form /tmp/testNUM.log where NUM is from 1 to number of logs requested to the supplied configuration DEFAULT CONFIG MUST BE SUPPLIED WITH AT LEAST ONE LOG BEING MONITORED (log being monitored will be overwritten - it is needed for json structure) returns the path of the config generated and a list of log stream names
func GenerateLogs ¶
func GenerateWindowsEvents ¶
func GenerateWindowsEvents(validationLog []models.LogValidation) error
func GetAnyEBSVolumeID ¶
GetAnyEBSVolumeID will return the volume ID of the first NVMe device found
func GetAnyInstanceStoreSerialID ¶
GetAnyInstanceStoreSerialID returns the serial ID of the first NVMe instance store device found.
func GetLogFilePaths ¶
GetLogFilePaths parses the cloudwatch agent config at the specified path and returns a list of the log files that the agent will monitor when using that config file
func InstallAgent ¶
InstallAgent can determine the package manager based on the installer suffix.
func ReadAgentLogfile ¶
func RecreateAgentLogfile ¶
func RecreateAgentLogfile(logfile string)
func ReplaceLocalStackHostName ¶
func ReplaceLocalStackHostName(pathIn string)
func ReplacePlaceholder ¶
ReplacePlaceholder replaces a placeholder string with a value in the specified file using sed command. This centralizes placeholder replacement functionality used across tests.
func ReplacePlaceholders ¶
ReplacePlaceholders replaces multiple placeholders in a single file placeholders is a map where key is the placeholder and value is the replacement
func RunAsyncCommand ¶
func RunCommand ¶
func RunCommands ¶
func SELinuxEnforced ¶
func SendAppSignalMetrics ¶
func SendCollectDMetrics ¶
func SendEMFMetrics ¶
func SendPrometheusMetrics ¶
func SendPrometheusMetrics(config PrometheusConfig, agentCollectionDuration time.Duration) error
func SendStatsdMetrics ¶
func StartAgentWithCommand ¶
func StartLogWrite ¶
func StartLogWrite(configFilePath string, duration time.Duration, sendingInterval time.Duration, logLinesPerMinute int) error
StartLogWrite starts go routines to write logs to each of the logs that are monitored by CW Agent according to the config provided
func StartSendingMetrics ¶
func StartSendingMetrics(receiver string, duration, sendingInterval time.Duration, metricPerInterval int, metricLogGroup, metricNamespace string) (err error)
StartSendingMetrics will generate metrics load based on the receiver (e.g 5000 statsd metrics per minute)
func UninstallAgent ¶
func UninstallAgent(pm PackageManager) error