Skip to content

Commit

Permalink
Add Nginx, Redis Postgress and soc listener plugins (AO-16696) (#24)
Browse files Browse the repository at this point in the history
* Add support for Nginx, Redis, Postgress and soc listener plugins (AO-16696)
  • Loading branch information
dominik-maslyk-swi authored Jul 2, 2020
1 parent 8822969 commit f1d987c
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKERFILE_VERSION=3.3.0
DOCKERFILE_VERSION=3.4.0
SWISNAP_VERSION=3.1.1.717
TAG=$(DOCKERFILE_VERSION)-$(SWISNAP_VERSION)
USER=solarwinds
Expand All @@ -12,7 +12,7 @@ build:

.PHONY: build-test
build-test:
@docker build -t $(CURRENT_IMAGE) -t $(LATEST_IMAGE) --build-arg swisnap_repo=swisnap --build-arg swisnap_version=$(SWISNAP_VERSION) .
@docker build -t $(CURRENT_IMAGE) -t $(LATEST_IMAGE) --build-arg swisnap_repo=swisnap-stg --build-arg swisnap_version=$(SWISNAP_VERSION) .

.PHONY: build-and-release-docker
build-and-release-docker: build
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,17 @@ The following environment parameters are available:
SWISNAP_ENABLE_APACHE | Set this to `true` to enable the Apache plugin.
SWISNAP_ENABLE_ELASTICSEARCH | Set this to `true` to enable the Elasticsearch plugin.
SWISNAP_ENABLE_KUBERNETES | Set this to `true` to enable the Kubernetes plugin. Enabling this option on the DaemonSet will cause replication of Kubernetes metrics where the replication count is the number of pods with Kubernetes collection enabled minus one. Typically Kubernetes collection is only enabled on the Deployment asset.
SWISNAP_ENABLE_NGINX | Set this to `true` to enable the Nginx plugin. If enabled the following ENV vars are required to be set:<br>*NGINX_STATUS_URI* - one, or multiple space-separeted link(s) to Nginx stub_status URI.
SWISNAP_ENABLE_NGINX_PLUS | Set this to `true` to enable the Nginx Plus plugin. If enabled the following ENV vars are required to be set:<br>*NGINX_PLUS_STATUS_URI* - one, or multiple space-separeted link(s) to ngx_http_status_module or status URI.
SWISNAP_ENABLE_NGINX_PLUS_API | Set this to `true` to enable the Nginx Plus Api plugin. If enabled the following ENV vars are required to be set:<br>*NGINX_PLUS_STATUS_URI* - one, or multiple space-separeted link(s) to Nginx API URI.
SWISNAP_ENABLE_MESOS | Set this to `true` to enable the Mesos plugin.
SWISNAP_ENABLE_MONGODB | Set this to `true` to enable the MongoDB plugin.
SWISNAP_ENABLE_MYSQL | Set this to `true` to enable the MySQL plugin. If enabled the following ENV vars are required to be set as well: MYSQL_USER, MYSQL_PASS, MYSQL_HOST & MYSQL_PORT
SWISNAP_ENABLE_PROMETHEUS | Set this to `true` to enable prometheus pod annotation scrapping
SWISNAP_ENABLE_MYSQL | Set this to `true` to enable the MySQL plugin. If enabled the following ENV vars are required to be set:<br>*MYSQL_USER*,<br>*MYSQL_PASS*,<br>*MYSQL_HOST*<br>*MYSQL_PORT*
SWISNAP_ENABLE_PROMETHEUS | Set this to `true` to enable the Prometheus pod annotation scrapping
SWISNAP_ENABLE_POSTGRESQL | Set this to `true` to enable the Postgres plugin. If enabled the following ENV vars are required to be set:<br>*POSTGRES_ADDRESS* - specify address for Postgres databse
SWISNAP_ENABLE_RABBITMQ | Set this to `true` to enable the RabbitMQ plugin.
SWISNAP_ENABLE_REDIS | Set this to `true` to enable the Redis plugin. If enabled the following ENV vars are required to be set:<br>*REDIS_SERVERS* - one, or multiple space-separeted link(s) to Redis servers
SWISNAP_ENABLE_SOCKET_LISTENER | Set this to `true` to enable the Socket Listener plugin. If enabled the following ENV vars are required to be set:<br>*SOCKET_SERVICE_ADDRESS* - URL to listen on,<br>*SOCKET_LISTENER_FORMAT* - Data format to consume: "collectd", "graphite", "influx", "json", or "value".
SWISNAP_ENABLE_STATSD | Set this to `true` to enable the Statsd plugin.
SWISNAP_ENABLE_ZOOKEEPER | Set this to `true` to enable the Zookeeper plugin.

Expand Down
79 changes: 77 additions & 2 deletions conf/swisnap-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ run_plugins_with_default_configs() {
if [ "$SWISNAP_ENABLE_DOCKER" = "true" ]; then
mv "${PLUGINS_DIR}/docker.yaml.example" "${PLUGINS_DIR}/docker.yaml"
if [[ -n "${HOST_PROC}" ]]; then
sed -i 's,procfs: "/proc",procfs: "'${HOST_PROC}'",g' "${PLUGINS_DIR}/docker.yaml"
sed -i 's,procfs: "/proc",procfs: "'"${HOST_PROC}"'",g' "${PLUGINS_DIR}/docker.yaml"
fi
fi

Expand All @@ -63,6 +63,45 @@ run_plugins_with_default_configs() {
mv "${PLUGINS_DIR}/kubernetes.yaml.example" "${PLUGINS_DIR}/kubernetes.yaml"
fi

if [ "${SWISNAP_ENABLE_NGINX}" = "true" ]; then
NGINX_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-nginx.yaml"
mv "${NGINX_CONFIG}.example" "${NGINX_CONFIG}"
if [[ -n "${NGINX_STATUS_URI}" ]]; then
yq d -i "${NGINX_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx.urls'
for nginx_uri in ${NGINX_STATUS_URI}; do
yq w -i "${NGINX_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx.urls[+]' "${nginx_uri}"
done
else
echo "WARNING: NGINX_STATUS_URI var was not set for Nginx plugin"
fi
fi

if [ "${SWISNAP_ENABLE_NGINX_PLUS}" = "true" ]; then
NGINX_PLUS_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-nginx_plus.yaml"
mv "${NGINX_PLUS_CONFIG}.example" "${NGINX_PLUS_CONFIG}"
if [[ -n "${NGINX_PLUS_STATUS_URI}" ]]; then
yq d -i "${NGINX_PLUS_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx_plus.urls'
for nginx_plus_uri in ${NGINX_PLUS_STATUS_URI}; do
yq w -i "${NGINX_PLUS_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx_plus.urls[+]' "${nginx_plus_uri}"
done
else
echo "WARNING: NGINX_PLUS_STATUS_URI var was not set for Nginx Plus plugin"
fi
fi

if [ "${SWISNAP_ENABLE_NGINX_PLUS_API}" = "true" ]; then
NGINX_PLUS_API_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-nginx_plus_api.yaml"
mv "${NGINX_PLUS_API_CONFIG}.example" "${NGINX_PLUS_API_CONFIG}"
if [[ -n "${NGINX_PLUS_API_URI}" ]]; then
yq d -i "${NGINX_PLUS_API_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx_plus_api.urls'
for nginx_plus_uri in ${NGINX_PLUS_API_URI}; do
yq w -i "${NGINX_PLUS_API_CONFIG}" 'plugins.(plugin_name==bridge).config.nginx_plus_api.urls[+]' "${nginx_plus_uri}"
done
else
echo "WARNING: NGINX_PLUS_API_URI var was not set for Nginx Plus Api plugin"
fi
fi

if [ "${SWISNAP_ENABLE_MESOS}" = "true" ]; then
mv "${PLUGINS_DIR}/mesos.yaml.example" "${PLUGINS_DIR}/mesos.yaml"
fi
Expand All @@ -75,6 +114,18 @@ run_plugins_with_default_configs() {
mv "${PLUGINS_DIR}/mysql.yaml.example" "${PLUGINS_DIR}/mysql.yaml"
if [[ -n "${MYSQL_USER}" && -n "${MYSQL_HOST}" && -n "${MYSQL_PORT}" ]]; then
yq w -i "${PLUGINS_DIR}/mysql.yaml" collector.mysql.all.mysql_connection_string "\"${MYSQL_USER}:${MYSQL_PASS}@tcp\(${MYSQL_HOST}:${MYSQL_PORT}\)\/\""
else
echo "WARNING: all: MYSQL_USER, MYSQL_HOST, MYSQL_PORT variables needs to be set for MySQL plugin"
fi
fi

if [ "${SWISNAP_ENABLE_POSTGRESQL}" = "true" ]; then
POSTGRES_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-postgresql.yaml"
mv "${POSTGRES_CONFIG}.example" "${POSTGRES_CONFIG}"
if [[ -n "${POSTGRES_ADDRESS}" ]]; then
yq w -i "${POSTGRES_CONFIG}" 'plugins.(plugin_name==bridge).config.postgresql.address' "${POSTGRES_ADDRESS}"
else
echo "WARNING: POSTGRES_ADDRESS var was not set for Postgres plugin."
fi
fi

Expand All @@ -89,6 +140,30 @@ run_plugins_with_default_configs() {
mv "${PLUGINS_DIR}/rabbitmq.yaml.example" "${PLUGINS_DIR}/rabbitmq.yaml"
fi

if [ "${SWISNAP_ENABLE_REDIS}" = "true" ]; then
REDIS_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-redis.yaml"
mv "${REDIS_CONFIG}.example" "${REDIS_CONFIG}"
if [[ -n "${REDIS_SERVERS}" ]]; then
yq d -i "${REDIS_CONFIG}" 'plugins.(plugin_name==bridge).config.redis.servers'
for redis_server in ${REDIS_SERVERS}; do
yq w -i "${REDIS_CONFIG}" 'plugins.(plugin_name==bridge).config.redis.servers[+]' "${redis_server}"
done
else
echo "WARNING: REDIS_SERVERS var was not set for Redis plugin."
fi
fi

if [ "${SWISNAP_ENABLE_SOCKET_LISTENER}" = "true" ]; then
SOCKET_LISTENER_CONFIG="${TASK_AUTOLOAD_DIR}/task-bridge-socket_listener.yaml"
mv "${SOCKET_LISTENER_CONFIG}.example" "${SOCKET_LISTENER_CONFIG}"
if [[ -n "${SOCKET_SERVICE_ADDRESS}" ]] && [[ -n "${SOCKET_DATA_FORMAT}" ]]; then
echo "INFO: setting service_address for Socket Listener plugin to ${SOCKET_SERVICE_ADDRESS} and data format to ${SOCKET_DATA_FORMAT}"
yq w -i "${SOCKET_LISTENER_CONFIG}" 'plugins.(plugin_name==bridge-stream).config.socket_listener.service_address' "${SOCKET_SERVICE_ADDRESS}"
yq w -i "${SOCKET_LISTENER_CONFIG}" 'plugins.(plugin_name==bridge-stream).config.socket_listener.data_format' "${SOCKET_DATA_FORMAT}"
else
echo "WARNING: both SOCKET_SERVICE_ADDRESS and SOCKET_DATA_FORMAT needs to be set for socket listener plugin"
fi
fi
if [ "${SWISNAP_ENABLE_STATSD}" = "true" ]; then
mv "${TASK_AUTOLOAD_DIR}/task-bridge-statsd.yaml.example" "${TASK_AUTOLOAD_DIR}/task-bridge-statsd.yaml"
fi
Expand Down Expand Up @@ -119,11 +194,11 @@ set_custom_tags() {
fi
}


main() {
swisnap_config_setup
run_plugins_with_default_configs
set_custom_tags
exec "${SWISNAP_HOME}/sbin/swisnapd" --config "${CONFIG_FILE}" "${FLAGS[@]}"
}

main
2 changes: 1 addition & 1 deletion deploy/overlays/stable/daemonset/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ bases:

images:
- name: solarwinds/solarwinds-snap-agent-docker
newTag: 3.3.0-3.1.1.717
newTag: 3.4.0-3.1.1.717
2 changes: 1 addition & 1 deletion deploy/overlays/stable/deployment/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bases:

images:
- name: solarwinds/solarwinds-snap-agent-docker
newTag: 3.3.0-3.1.1.717
newTag: 3.4.0-3.1.1.717
2 changes: 1 addition & 1 deletion deploy/overlays/stable/events-collector/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ bases:

images:
- name: solarwinds/solarwinds-snap-agent-docker
newTag: 3.3.0-3.1.1.717
newTag: 3.4.0-3.1.1.717

0 comments on commit f1d987c

Please sign in to comment.