diff --git a/Dockerfile b/Dockerfile index 12ee02b4..a1c8add0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,40 @@ FROM golang:alpine AS builder + + ADD . $GOPATH/src/github.com/citrusleaf/aerospike-prometheus-exporter WORKDIR $GOPATH/src/github.com/citrusleaf/aerospike-prometheus-exporter -RUN apk add git \ +RUN apk add git\ + && apk add gettext libintl \ && go get ./... \ && go build -o aerospike-prometheus-exporter . \ && cp aerospike-prometheus-exporter /aerospike-prometheus-exporter + FROM golang:alpine +ENV AGENT_UPDATE_INTERVAL=5\ + AGENT_CERT_FILE=""\ + AGENT_KEY_FILE=""\ + AGENT_TAGS='"agent","aerospike"'\ + AGENT_BIND_HOST=""\ + AGENT_BIND_PORT=9145\ + AGENT_TIMEOUT=10\ + AGENT_LOG_LEVEL="info"\ + AS_HOST=""\ + AS_PORT=3000\ + AS_CERT_FILE=""\ + AS_KEY_FILE=""\ + AS_NODE_TLS_NAME=""\ + AS_ROOT_CA=""\ + AS_AUTH_MODE=""\ + AS_AUTH_USER=""\ + TICKER_INTERVAL=5\ + TICKER_TIMEOUT=5 + +RUN apk add gettext libintl COPY --from=builder /aerospike-prometheus-exporter /usr/bin/aerospike-prometheus-exporter -CMD ["-h localhost", "-p 3000", "-b :9145", "-tags agent,aerospike"] -ENTRYPOINT ["aerospike-prometheus-exporter"] +COPY ape.toml.template /etc/aerospike-prometheus-exporter/ape.toml.template +# you could change the port via env var and then would have to --expose in run. +# That is likely unnecessary though +EXPOSE 9145 + +CMD cat /etc/aerospike-prometheus-exporter/ape.toml.template && env && envsubst < /etc/aerospike-prometheus-exporter/ape.toml.template > /etc/aerospike-prometheus-exporter/ape.toml && cat /etc/aerospike-prometheus-exporter/ape.toml && aerospike-prometheus-exporter -config /etc/aerospike-prometheus-exporter/ape.toml diff --git a/README.md b/README.md index ed330e21..042829f2 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,6 @@ This repo contains Aerospike's monitoring agent for Prometheus. -1. Install Go v1.12+, and Docker for your platform. -2. Run `go get github.com/citrusleaf/aerospike-prometheus-exporter` and cd to it via: `cd $GOPATH/src/github.com/citrusleaf/aerospike-prometheus-exporter` -3. `go build -o aerospike-prometheus-exporter . && ./aerospike-prometheus-exporter -config ` builds and runs the agent. - - 3.1. for a second agent on the same machine, bind it to a different port: `go build . && ./aerospike-prometheus-exporter -config ` -4. Edit `docker/prometheus/prometheus.yml` and change the target IPs to aerospike-prometheus-exporter installations. -5. Run `docker-compose up` to download, build and run the docker images. To stop the containers, run `docker-compose down` -6. Go to your browser and use the URL: `http://localhost:3000`. User/Pass is `admin/pass` -7. Prometheus dashboard is at: `http://localhost:9090` - - 7.1. To make a dashboard your default, first choose that dashboard, and then star it on the toolbar on top right of the screen. After that, you can go to grafana preferences and choose that starred dashboard as default. - 1. Install Go v1.12+ 1. Run `go get github.com/citrusleaf/aerospike-prometheus-exporter` and cd to it via: `cd $GOPATH/src/github.com/citrusleaf/aerospike-prometheus-exporter` 1. `go build -o aerospike-prometheus-exporter . && ./aerospike-prometheus-exporter -config ` builds and runs the agent. @@ -34,7 +22,7 @@ This repo contains Aerospike's monitoring agent for Prometheus. ``` - Example run ``` - docker run -itd --name exporter1 aerospike/aerospike-prometheus-exporter:latest -h 172.17.0.2 -p 3000 -b :9145 -tags agent1,aero_cluster + docker run -itd --name exporter1 aerospike/aerospike-prometheus-exporter:latest -e AS_HOST=172.17.0.2 -e AS_PORT=3000 -e AGENT_TAGS='"agent1","aero_cluster"' ``` Enjoy! diff --git a/ape.toml.template b/ape.toml.template new file mode 100644 index 00000000..666aa5b4 --- /dev/null +++ b/ape.toml.template @@ -0,0 +1,45 @@ +[Agent] +update_interval = ${AGENT_UPDATE_INTERVAL} +# File paths should be double quoted. +# Certificate file for the metric servers for prometheus +cert_file = "${AGENT_CERT_FILE}" +# Key file for the metric servers for prometheus +key_file = "${AGENT_KEY_FILE}" + +# tags to append to the prometheus metrics +tags=[${AGENT_TAGS}] + +bind_host = "${AGENT_BIND_HOST}" +bind_port = ${AGENT_BIND_PORT} + +# metrics server timeout in seconds +timeout = ${AGENT_TIMEOUT} + +# debug level can be info|warning,warn|error,err|debug +log_level = "${AGENT_LOG_LEVEL}" + +[Aerospike] +db_host="${AS_HOST}" +db_port=${AS_PORT} + +# certificate file +cert_file="${AS_CERT_FILE}" +# key file +key_file="${AS_KEY_FILE}" +# node TLS name for authentication +node_tls_name="${AS_NODE_TLS_NAME}" +# root certificate file +root_ca="${AS_ROOT_CA}" + +# authentication mode: internal (for server), external (LDAP, etc.) +auth_mode="${AS_AUTH_MODE}" +# database user +user="${AS_AUTH_USER}" +# database password +password="$AS_AUTH_USER" + +# ticker interval for requesting stats fro mthe database node +resolution=${TICKER_INTERVAL} + +# timeout for sending commands to the server node in seconds +timeout=${TICKER_TIMEOUT} diff --git a/cert.pem b/cert.pem deleted file mode 100644 index cc5c2716..00000000 --- a/cert.pem +++ /dev/null @@ -1,12 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIBwjCCAUegAwIBAgIRAMW4Iz08Pc4bkFEsv4u6QTYwCgYIKoZIzj0EAwMwEjEQ -MA4GA1UEChMHQWNtZSBDbzAeFw0yMDAyMTQxNzE4MjlaFw0yMTAyMTMxNzE4Mjla -MBIxEDAOBgNVBAoTB0FjbWUgQ28wdjAQBgcqhkjOPQIBBgUrgQQAIgNiAATP8IwV -Jovx6Z06wFHeh1CZjei6GZ5skupM1L1yx8m6V2E0jdvNBiqCM8A7AzZiTjPd1KSN -/Abq1TnuNTapL8zeYHjAbCMIygRSHy+RBtLH6aysAKLy1c3flNosMNMgFUujYTBf -MA4GA1UdDwEB/wQEAwICpDATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHRMBAf8E -BTADAQH/MCcGA1UdEQQgMB6CCWxvY2FsaG9zdIILZXhhbXBsZS5jb22HBH8AAAEw -CgYIKoZIzj0EAwMDaQAwZgIxAJE67DXIaW4turbFwoCwhiH0HOEVteRQLMpxBBi2 -UmIIH4K1kwKxuHITXNCbRW7DzwIxAMLDc7mrWYkGnCVxfhfl/HM9TdYhsNyEMeOp -pTmNMMUEl5LxHXkM9gjOZMlahogLhw== ------END CERTIFICATE----- diff --git a/key.pem b/key.pem deleted file mode 100644 index 66df9464..00000000 --- a/key.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIG2AgEAMBAGByqGSM49AgEGBSuBBAAiBIGeMIGbAgEBBDBeZJxCl+K/IaeRvQRO -LownJpIdYFt3Z6X4W1cdZF/+bYeE4mAc9owi8MFiW4Vo5GuhZANiAATP8IwVJovx -6Z06wFHeh1CZjei6GZ5skupM1L1yx8m6V2E0jdvNBiqCM8A7AzZiTjPd1KSN/Abq -1TnuNTapL8zeYHjAbCMIygRSHy+RBtLH6aysAKLy1c3flNosMNMgFUs= ------END PRIVATE KEY-----