Examples of running Zenoss' statsd (gostatsd) using docker-compose or Kubernetes to forward metrics from custom applications written in various languages.
These app examples are setup to be run locally using docker-compose, or run on a Kubernetes cluster.
Both the docker-compose and Kubernetes options require that you first set the following environment variables. These control the Zenoss stack and tenant to which the example apps will publish their data.
export ZENOSS_ADDRESS="api.zenoss.io:443"
export ZENOSS_API_KEY="YOUR-API-KEY-HERE"
export NAMESPACE="UNIQUE-VALUE-HERE"
Setting NAMESPACE allows your example data to be different than others who may be sending data from these examples to the same Zenoss tenant. A single lowercase word should be used. For example, my email address within my organization starts with "cluther", so I might set NAMESPACE to "cluther".
To run using docker-compose you don't need to build anything in advance because docker-compose will build the necessary images before running them in containers.
Running gostatsd, the requester app, and all example apps can be done with the following command.
make docker-up
To see the logs for all of these containers you can run the following.
make docker-logs
To stop all of the containers you can run the following.
make docker-down
To run on Kubernetes you must first build and push images for the requester app, and all example apps to an image repository to which your Kubernetes cluster has access.
Currently this repository is hard-coded in Makefile.common with the following lines.
IMAGE_REPOSITORY := gcr.io/zing-registry-188222
IMAGE_PREFIX := zenoss/app-examples
Run the following command to build and push all required images to this repository.
make push-images
Deploying gostatsd, the requester app, and all example apps to your current
(kubectl config current-context) Kubernetes context can be done with the
following command. Note that this creates an app-examples namespace, and
deploys everything to that namespace.
make kubernetes-up
To see the logs for all of the containers you can run the following. Note that this requires that you first install the stern Kubernetes log tool.
make kubernetes-logs
To destroy the app-examples namespace, and everything deployed to it, run the following command.
make kubernetes-down
More example apps can be added to this repository by following the examples that already exist.
- Create a directory for the app.
- Add a self-contained app to the directory.
- Add a Makefile, Dockerfile, and kubernetes.yml to the directory.
- Add the app to APPS at the top of Makefile.
- Add the app to the command list of the requester service in docker-compose.yml.
- Add the app to the command list of the requester deployment in kubernetes.yml.in.