Introduction
The cloud-init package (installed by default on a variety of modern distributions) can be used to automatically install and configure the Scalyr Agent. This is especially useful when working with ephemeral hosts.
Configuration
I created the following cloud-init script to be executed from within an AWS EC2 launch template (although the embedded bash script could be used in a variety of other scenarios).
It installs the Scalyr Agent, sets up a configuration file with optimized defaults, and starts the Scalyr Agent:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="
--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"
#!/bin/bash
wget -q https://www.scalyr.com/scalyr-repo/stable/latest/install-scalyr-agent-2.sh && \
sudo bash ./install-scalyr-agent-2.sh && \
sudo tee /etc/scalyr-agent-2/agent.json > /dev/null << '_endmsg' && sudo scalyr-agent-2 start
{
api_key: "ABCXYZ-",
compression_type: "deflate",
compression_level: 6,
max_allowed_request_size: 4900000,
pipeline_threshold: 0.1,
min_request_spacing_interval: 0.5,
max_request_spacing_interval: 1.0,
max_log_offset_size: 200000000,
max_existing_log_offset_size: 200000000,
implicit_metric_monitor: false,
implicit_agent_process_metrics_monitor: false,
logs: [
{ path: "/var/log/logfile", attributes: {parser: "myLogfile"} }
],
}
_endmsg
--==MYBOUNDARY==--
Comments
0 comments
Please sign in to leave a comment.