Skip to content

Commit

Permalink
Merge branch 'main' into windows-dl-prog-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
LMarkie authored Feb 14, 2024
2 parents 098c3e5 + 65194e4 commit 4d1b3aa
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 72 deletions.
40 changes: 20 additions & 20 deletions linux/observability-agent-autoconf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ if ! which curl >/dev/null; then
yum -y install curl
elif [ "$OS" = "SUSE" ]; then
echo "Installing curl..."
zypper -y install curl
zypper install -y curl
elif [ "$OS" = "macOS" ]; then
echo "curl required"
exit 1
Expand All @@ -131,7 +131,7 @@ if ! which tar >/dev/null; then
yum -y install tar
elif [ "$OS" = "SUSE" ]; then
echo "Installing tar..."
zypper -y install tar
zypper install -y tar
elif [ "$OS" = "macOS" ]; then
echo "tar required"
exit 1
Expand All @@ -151,7 +151,7 @@ if ! which ss >/dev/null; then
yum -y install iproute2
elif [ "$OS" = "SUSE" ]; then
echo "Installing iproute2..."
zypper -y install iproute2
zypper install -y iproute2
elif [ "$OS" = "macOS" ]; then
echo "iproute2mac required"
exit 1
Expand All @@ -171,7 +171,7 @@ if ! which jq >/dev/null; then
yum -y install jq
elif [ "$OS" = "SUSE" ]; then
echo "Installing jq..."
zypper -y install jq
zypper install -y jq
elif [ "$OS" = "macOS" ]; then
echo "jq required"
exit 1
Expand All @@ -192,8 +192,7 @@ if [ "$INSTALL" != false ]; then
if [ "$ARCH" != "unsupported" ]; then
echo "Downloading binary..."
# download the binary
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/grafana/agent/releases/latest | jq ".assets[] | select((.name | test(\"flow\")) and (.name|match(\"darwin-$ARCH.zip$\"))) | .browser_download_url" | tr -d '"')
curl -LO "$DOWNLOAD_URL"
curl -O -L "https://github.com/grafana/agent/releases/download/v0.39.2/grafana-agent-darwin-$ARCH.zip"
# extract the binary
unzip "grafana-agent-darwin-$ARCH.zip"
# make sure it is executable
Expand All @@ -209,19 +208,17 @@ if [ "$INSTALL" != false ]; then
else
if [ "$OS" = "Debian" ]; then
if [ "$ARCH" != "unsupported" ]; then
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/grafana/agent/releases/latest | jq '.assets[] | select((.name | test("flow")) and (.name | endswith("'"$ARCH.deb"'"))) | .browser_download_url' | tr -d '"')
curl -LO "$DOWNLOAD_URL"
dpkg -i "$(basename "$DOWNLOAD_URL")"
curl -O -L "https://github.com/grafana/agent/releases/download/v0.39.2/grafana-agent-flow-0.39.2-1.$ARCH.deb"
dpkg -i "grafana-agent-flow-0.39.2-1.$ARCH.deb"
else
echo "Architecture not supported"
exit 1;
fi

elif [ "$OS" = "RedHat" ] || [ "$OS" = "SUSE" ]; then
if [ "$ARCH" != "unsupported" ]; then
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/grafana/agent/releases/latest | jq '.assets[] | select((.name | test("flow")) and (.name | endswith("'"$ARCH.rpm"'"))) | .browser_download_url' | tr -d '"')
curl -LO "$DOWNLOAD_URL"
rpm -i "$(basename "$DOWNLOAD_URL")"
curl -O -L "https://github.com/grafana/agent/releases/download/v0.39.2/grafana-agent-flow-0.39.2-1.$ARCH.rpm"
rpm -i "grafana-agent-flow-0.39.2-1.$ARCH.rpm"
#change after config updated
else
echo "Architecture not supported"
Expand All @@ -231,12 +228,12 @@ if [ "$INSTALL" != false ]; then
echo "OS not supported, downloading binary..."
# Download the binary
# Can't install jq if OS is unknown, therefore can't get latest binary
curl -O -L "https://github.com/grafana/agent/releases/download/v0.34.0/grafana-agent-flow-0.34.2-1.$ARCH.zip"
curl -O -L "https://github.com/grafana/agent/releases/download/v0.39.2/grafana-agent-flow-0.39.2-1.$ARCH.zip"
# extract the binary
unzip "grafana-agent-flow-0.34.2-1.$ARCH.zip"
unzip "grafana-agent-flow-0.39.2-1.$ARCH.zip"
# make sure it is executable
chmod a+x "grafana-agent-flow-0.34.2-1.$ARCH.zip"
binLocation="$(pwd)/grafana-agent-flow-0.34.2-1.$ARCH.zip"
chmod a+x "grafana-agent-flow-0.39.2-1.$ARCH.zip"
binLocation="$(pwd)/grafana-agent-flow-0.39.2-1.$ARCH.zip"
# echo the location of the binary
echo "Binary location: $binLocation"
asBinary=true
Expand Down Expand Up @@ -359,14 +356,14 @@ while true; do

# Add log collection
cat <<EOF >> "$CONFIG"
discovery.file "varlog" {
local.file_match "varlog" {
path_targets = [
{__path__ = "$path", job = "$job"},
]
}
loki.source.file "httpd" {
targets = discovery.file.varlog.targets
targets = local.file_match.varlog.targets
forward_to = [loki.write.lokiEndpoint.receiver]
}
Expand Down Expand Up @@ -670,11 +667,12 @@ if { (ss -ltn | grep -qE :5672) || [ -n "${rabbitmq_scrape_target}" ]; } && [ "$
if ! (ss -ltn | grep -qE :15692); then
echo "RabbitMQ exporter is not enabled, see the Observability Agent docs to learn how to enable it"
fi
instance_label=${rabbitmq_instance_label:=${rabbitmq_scrape_target:="127.0.0.1:15692"}}
if [ -n "${rabbitmq_scrape_target}" ]; then
cat <<EOF >> "$CONFIG"
prometheus.scrape "rabbit" {
targets = [
{"__address__" = "$rabbitmq_scrape_target", "instance" = "one"},
{"__address__" = "$rabbitmq_scrape_target", "instance" = "${instance_label}"},
]
forward_to = [prometheus.remote_write.default.receiver]
Expand All @@ -685,7 +683,7 @@ EOF
cat <<EOF >> "$CONFIG"
prometheus.scrape "rabbit" {
targets = [
{"__address__" = "127.0.0.1:15692", "instance" = "one"},
{"__address__" = "127.0.0.1:15692", "instance" = "${instance_label}"},
]
forward_to = [prometheus.remote_write.default.receiver]
Expand Down Expand Up @@ -1040,6 +1038,8 @@ if [ "${asBinary}" = true ]; then
elif [ "$PROMPT" != false ] || [ "${start_service}" = true ]; then
mv $CONFIG /etc/grafana-agent-flow.river
echo "Config file can be found at /etc/grafana-agent-flow.river"
systemctl enable grafana-agent-flow.service
echo "Grafana Agent Flow enabled"
systemctl start grafana-agent-flow.service
echo "Grafana Agent Flow started"
fi
42 changes: 42 additions & 0 deletions linux/observability-agent-uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# OS/Distro Detection
# Try lsb_release, fallback with /etc/issue then uname command
KNOWN_DISTRIBUTION="(Debian|Ubuntu|RedHat|CentOS|openSUSE|Amazon|Arista|SUSE|Rocky|AlmaLinux|Darwin)"
DISTRIBUTION=$(lsb_release -d 2>/dev/null | grep -Eo $KNOWN_DISTRIBUTION || grep -Eo $KNOWN_DISTRIBUTION /etc/issue 2>/dev/null || grep -Eo $KNOWN_DISTRIBUTION /etc/Eos-release 2>/dev/null || grep -m1 -Eo $KNOWN_DISTRIBUTION /etc/os-release 2>/dev/null || uname -s)

if [ -f /etc/debian_version ] || [ "$DISTRIBUTION" = "Debian" ] || [ "$DISTRIBUTION" = "Ubuntu" ]; then
OS="Debian"
elif [ -f /etc/redhat-release ] || [ "$DISTRIBUTION" = "RedHat" ] || [ "$DISTRIBUTION" = "CentOS" ] || [ "$DISTRIBUTION" = "Amazon" ] || [ "$DISTRIBUTION" = "Rocky" ] || [ "$DISTRIBUTION" = "AlmaLinux" ]; then
OS="RedHat"
# Some newer distros like Amazon may not have a redhat-release file
elif [ -f /etc/system-release ] || [ "$DISTRIBUTION" = "Amazon" ]; then
OS="RedHat"
# Arista is based off of Fedora14/18 but do not have /etc/redhat-release
elif [ -f /etc/Eos-release ] || [ "$DISTRIBUTION" = "Arista" ]; then
OS="RedHat"
# openSUSE and SUSE use /etc/SuSE-release or /etc/os-release
elif [ -f /etc/SuSE-release ] || [ "$DISTRIBUTION" = "SUSE" ] || [ "$DISTRIBUTION" = "openSUSE" ]; then
OS="SUSE"
else
echo "Distribution not supported"
exit 0
fi
echo "$OS detected"


echo "Uninstalling grafana-agent-flow"
systemctl stop grafana-agent-flow

if [ "$OS" = "Debian" ]; then
apt-get -y remove grafana-agent-flow
rm -i /etc/apt/sources.list.d/grafana.list
elif [ "$OS" = "RedHat" ]; then
dnf -y remove grafana-agent-flow
rm -i /etc/yum.repos.d/rpm.grafana.repo
elif [ "$OS" = "SUSE" ]; then
zypper remove -y grafana-agent-flow
zypper removerepo grafana
fi
systemctl daemon-reload
echo "Uninstall Complete"
47 changes: 25 additions & 22 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ To modify a pre-existing config file, add `--config.file`, followed by the path
`sudo path/to/observability-agent-autoconf.sh --config.file path/to/configfile`
A backup of your original file will be created

To disable prompts that wait for user input, add `--prompt false` as command arguments.

You can use both `--install` and `--config.file` options in the same run command, order is irrelevant. For example: </br>
`sudo path/to/observability-agent-autoconf.sh --install false --config.file path/to/config`</br>
or </br>
Expand All @@ -82,28 +84,29 @@ To add integrations without being prompted for credentials, there are several en

### Metric Exporters

| Variable | Type | Description |
|--------------------------|----------|-------------------------------------------------------------------|
| `mysql_user` | `string` | User for the local Mysql database |
| `mysql_password` | `string` | Password for the local Mysql database |
| `mysql_disabled` | `bool` | Enables/Disables the Mysql exporter (enabled by default) |
| `mssql_user` | `string` | User for the local Mssql database |
| `mssql_password` | `string` | Password for the local Mssql database |
| `mssql_disabled` | `bool` | Enables/Disables the Mssql exporter (enabled by default) |
| `postgres_user` | `string` | User for the local Postgres database |
| `postgres_password` | `string` | Password for the local Postgres database |
| `postgres_disabled` | `bool` | Enables/Disables the Postgres exporter (enabled by default) |
| `rabbitmq_disabled` | `bool` | Enables/Disables the RabbitMQ exporter (enabled by default) |
| `redis_disabled` | `bool` | Enables/Disables the Redis exporter (enabled by default) |
| `elasticsearch_user` | `string` | User for the Elastic search instance |
| `elasticsearch_password` | `string` | Password for the Elastic search instance |
| `elasticsearch_disabled` | `bool` | Enables/Disables the Elastic search exporter (enabled by default) |
| `mongodb_user` | `string` | User for the local Mongo database |
| `mongodb_password` | `string` | Password for the local Mongo database |
| `mongodb_disabled` | `bool` | Enables/Disables the MongoDB exporter (enabled by default) |
| `oracledb_user` | `string` | User for the local Oracle database |
| `oracledb_password` | `string` | Password for the local Oracle database |
| `oracledb_disabled` | `bool` | Enables/Disables the OracleDB exporter (enabled by default) |
| Variable | Type | Description |
|---------------------------|----------|-------------------------------------------------------------------|
| `mysql_user` | `string` | User for the local Mysql database |
| `mysql_password` | `string` | Password for the local Mysql database |
| `mysql_disabled` | `bool` | Enables/Disables the Mysql exporter (enabled by default) |
| `mssql_user` | `string` | User for the local Mssql database |
| `mssql_password` | `string` | Password for the local Mssql database |
| `mssql_disabled` | `bool` | Enables/Disables the Mssql exporter (enabled by default) |
| `postgres_user` | `string` | User for the local Postgres database |
| `postgres_password` | `string` | Password for the local Postgres database |
| `postgres_disabled` | `bool` | Enables/Disables the Postgres exporter (enabled by default) |
| `rabbitmq_disabled` | `bool` | Enables/Disables the RabbitMQ exporter (enabled by default) |
| `rabbitmq_instance_label` | `string` | Optional variable to set the RabbitMQ instance identifier |
| `redis_disabled` | `bool` | Enables/Disables the Redis exporter (enabled by default) |
| `elasticsearch_user` | `string` | User for the Elastic search instance |
| `elasticsearch_password` | `string` | Password for the Elastic search instance |
| `elasticsearch_disabled` | `bool` | Enables/Disables the Elastic search exporter (enabled by default) |
| `mongodb_user` | `string` | User for the local Mongo database |
| `mongodb_password` | `string` | Password for the local Mongo database |
| `mongodb_disabled` | `bool` | Enables/Disables the MongoDB exporter (enabled by default) |
| `oracledb_user` | `string` | User for the local Oracle database |
| `oracledb_password` | `string` | Password for the local Oracle database |
| `oracledb_disabled` | `bool` | Enables/Disables the OracleDB exporter (enabled by default) |

### Exporting metrics from external machines

Expand Down
Loading

0 comments on commit 4d1b3aa

Please sign in to comment.