Permalink
Browse files

Add Linkerd-viz for instance metric aggregation

  • Loading branch information...
muteor committed Nov 9, 2016
1 parent 631d4b1 commit 5238050ffba316b359dbd9376077692dc4c4bb36
@@ -8,6 +8,9 @@ services:
cd forex-exchange-rate && \
docker build -t muteor/forex-exchange-rate:latest . && \
cd ../
cd linkerd-viz && \
docker build -t muteor/linkerd-viz:latest . && \
cd ../
refresh: services
cd rancher/forex && \
@@ -7,6 +7,10 @@ for me to try things out.
Hopefully as I get time I will add more features or experiment with
other tools.
## Updates
* 10th November 2016 - Added Linkerd-viz to aggregate linkerd instance metrics
## Building/Running
You can build the services using:
@@ -17,8 +21,9 @@ They depend on my base images https://hub.docker.com/u/muteor/
Then you need Rancher and its cli tools and can do:
`cd rancher/consul-registrator && rancher-compose up`
`cd rancher/forex && rancher-compose up`
`cd rancher/consul-registrator && rancher-compose up -d`
`cd rancher/forex && rancher-compose up -d`
`cd rancher/mertics && rancher-compose up -d`
## Design
@@ -137,11 +142,19 @@ exchange rate service.
* Forex Exchange Rate - This provides exchange rate data, based on the ECB
90 day data.
## Metrics
### Linkerd-viz
The official linkerd-viz is not used, but the same setup using Prometheus
and Grafana is, this aggregates data from linkerd instances into a single
set of dashboards. See [](linkerd-viz/README.md) for details.
## TODO
* Logging
* Aggregate container logs, debugging be hard currently
* Aggregate linkerd logs
* ~~Aggregate linkerd logs~~
* Development
* Make it easier to run service without having to docker build
* Tools
@@ -12,7 +12,7 @@ routers:
# This server should be registered in service discovery so that incoming traffic
# is served here.
- protocol: http
label: incoming
label: incoming-forex-currency-converter
servers:
- port: 4140
ip: 0.0.0.0
@@ -12,7 +12,7 @@ routers:
# This server should be registered in service discovery so that incoming traffic
# is served here.
- protocol: http
label: incoming
label: incoming-forex-exchange-rate
servers:
- port: 4140
ip: 0.0.0.0
@@ -0,0 +1,19 @@
FROM grafana/grafana:3.1.1
RUN apt-get update && \
apt-get -y --no-install-recommends install curl
COPY linkerd-viz /
COPY prometheus-consul.yml /
ADD https://github.com/prometheus/prometheus/releases/download/v1.3.1/prometheus-1.3.1.linux-amd64.tar.gz /prom.tar.gz
RUN mkdir -p /prometheus/data && \
tar -zxf /prom.tar.gz -C /prometheus --strip-components=1
RUN mkdir -p /grafana/dashboards
COPY linkerd-viz-dashboard-out.json /grafana/dashboards/outgoing.json
COPY linkerd-viz-dashboard-in.json /grafana/dashboards/incoming.json
EXPOSE 3000 9090
ENTRYPOINT [ "/linkerd-viz" ]
@@ -0,0 +1,14 @@
# Linkerd-viz Consul
This is heavily inspired by https://github.com/BuoyantIO/linkerd-viz but that repo
didn't work out-of-box for my setup, therefore I created my own configs and docker images.
Linkerd-viz uses Prometheus and Grafana to aggregate and display Linkerd instance metrics.
None of this is production ready/tested, but hopefully helpful as a config example.
As this example uses [Linker-to-linkerd](https://linkerd.io/in-depth/deployment/)
communication we have two routers per instance, one that proxies requests to the
local app and another that routes to the other app instances. Therefore we have two
dashboards in Grafana inbound which aggregates the data for the local app router and
outbound for the app instance router.
@@ -0,0 +1,60 @@
#!/bin/sh
#
# Boot prometheus and grafana
#
# usage:
# ./linkerd-viz
PUBLIC_PORT="3000"
STATS_PORT="9090"
#
# init grafana
#
grafana_ini=$(cat <<EOF
[auth.anonymous]
enabled = true
org_role = Admin
[dashboards.json]
enabled = true
path = /grafana/dashboards
[server]
http_port = $PUBLIC_PORT
EOF
)
printf "%s\n" "$grafana_ini" > /etc/grafana/grafana.ini
/run.sh &
prometheus_data_source=$(cat <<EOF
{
"access": "proxy",
"isDefault": true,
"jsonData": {},
"name": "prometheus",
"type": "prometheus",
"url": "http://localhost:$STATS_PORT"
}
EOF
)
until $(curl -sfo /dev/null http://localhost:$PUBLIC_PORT/api/datasources); do
# wait for grafana to boot
sleep 1
done
curl -vX POST -d "${prometheus_data_source}" -H "Content-Type: application/json" http://localhost:$PUBLIC_PORT/api/datasources
curl -vX PUT -d"{\"theme\": \"dark\"}" -H "Content-Type: application/json" http://localhost:$PUBLIC_PORT/api/org/preferences
#
# init prometheus
#
/prometheus/prometheus \
-config.file=/prometheus-consul.yml \
-storage.local.path=/prometheus/data \
-web.console.libraries=/prometheus/console_libraries \
-web.console.templates=/prometheus/consoles \
-web.listen-address=:$STATS_PORT
Oops, something went wrong.

0 comments on commit 5238050

Please sign in to comment.