Skip to content

Commit

Permalink
initial commit, dcos and k8s support
Browse files Browse the repository at this point in the history
  • Loading branch information
siggy committed Oct 5, 2016
1 parent f00dc62 commit 62b9d0a
Show file tree
Hide file tree
Showing 11 changed files with 2,531 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM grafana/grafana:3.1.1
MAINTAINER Buoyant, Inc. <hello@buoyant.io>

RUN apt-get update && \
apt-get -y --no-install-recommends install curl

COPY . /
COPY etc/grafana/dashboards/linkerd-viz-dashboard.json /usr/share/grafana/public/dashboards/home.json

EXPOSE 3000 9090

ENTRYPOINT [ "/linkerd-viz" ]
54 changes: 53 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# linkerd-viz
Dead simple monitoring for linkerd

Dead simple monitoring for [linkerd](https://linkerd.io).

![linkerd-viz screenshot](https://linkerd.io/images/dcos/linkerd-viz-screenshot.png "linkerd-viz screenshot")

linkerd-viz is a monitoring application based on
[Prometheus](https://prometheus.io/) and [Grafana](http://grafana.org/),
autoconfigured to collect metrics from [linkerd](https://linkerd.io).
linkerd-viz currently supports [Kubernetes](http://kubernetes.io/) and
[DC/OS](https://dcos.io/).

linkerd-viz assumes linkerd has already been deployed onto your cluster, and
your applications have been configured to route via linkerd. For more
information on getting started with linkerd have a look at our [Getting Started
guides](https://linkerd.io/getting-started/).

## Build and push Docker image

```bash
./dockerize [docker-tag]
```

Default `docker-tag` is `buoyantio/linkerd-viz:latest`

## Local boot

```bash
docker run -p 3000:3000 -p 9090:9090 buoyantio/linkerd-viz
```

## Kubernetes Deploy

```bash
kubectl apply -f linkerd-viz-k8s.yml
```

View dashboard

```bash
open http://$(kubectl get svc linkerd-viz -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
```

## DC/OS Deploy

```bash
dcos marathon app add linkerd-viz-dcos.json
```

View dashboard

```bash
open $PUBLIC_NODE:3000
```
46 changes: 46 additions & 0 deletions dockerize
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/sh
#
# Build a prometheus+grafana docker image to collect linkerd metrics.
#
# usage:
# dockerize [docker-tag]

set -e

VIZ_TAG="buoyantio/linkerd-viz:latest"
if [ "$1" != "" ]; then
VIZ_TAG="$1"
fi

BUILD=/tmp/linkerd-viz
PROM_TAG=prom/prometheus:v1.1.3
GRAF_TAG=grafana/grafana:3.1.1

rm -rf $BUILD
mkdir -p $BUILD/bin
mkdir -p $BUILD/etc/prometheus
mkdir -p $BUILD/etc/grafana/dashboards

cp Dockerfile $BUILD/Dockerfile
cp linkerd-viz $BUILD/linkerd-viz
cp prometheus-*.yml $BUILD/etc/prometheus/
cp grafana.ini $BUILD/etc/grafana/grafana.ini
cp prometheus_data_source.json $BUILD/etc/grafana/prometheus_data_source.json
cp linkerd-viz-dashboard.json $BUILD/etc/grafana/dashboards/linkerd-viz-dashboard.json

docker pull $PROM_TAG
docker rm -vf prom-build >/dev/null 2>&1 || true
docker run --name=prom-build $PROM_TAG &

echo "waiting for $PROM_TAG to boot"
sleep 5

docker cp prom-build:/bin/prometheus $BUILD/bin/prometheus
docker cp prom-build:/bin/promtool $BUILD/bin/promtool
docker cp prom-build:/etc/prometheus/console_libraries/ $BUILD/etc/prometheus/console_libraries
docker cp prom-build:/etc/prometheus/consoles/ $BUILD/etc/prometheus/consoles

docker rm -vf prom-build >/dev/null 2>&1 || true

docker build --tag=$VIZ_TAG $BUILD
docker push $VIZ_TAG
10 changes: 10 additions & 0 deletions grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[auth.anonymous]
enabled = true
org_role = Admin

[dashboards.json]
enabled = true
path = /etc/grafana/dashboards

[server]
http_port = PUBLIC_PORT
35 changes: 35 additions & 0 deletions linkerd-viz
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/sh
#
# Boot prometheus and grafana
#
# usage:
# ./linkerd-viz [platform]
#
# platform can be one of: [dcos, k8s]

PLATFORM="${1:-dcos}"
PUBLIC_PORT="${PUBLIC_PORT:-3000}"
STATS_PORT="${STATS_PORT:-9090}"

# on first run write env vars into config files
# TODO: auto-gen these in place
sed -itmp "s@PUBLIC_PORT@$PUBLIC_PORT@" /etc/grafana/grafana.ini
sed -itmp "s@STATS_PORT@$STATS_PORT@" /etc/grafana/prometheus_data_source.json

# boot grafana
/run.sh &

until $(curl -sfo /dev/null http://localhost:$PUBLIC_PORT/api/datasources); do
# wait for grafana to boot
sleep 1
done
curl -vX POST -d @/etc/grafana/prometheus_data_source.json -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

# boot prometheus
/bin/prometheus \
-config.file=/etc/prometheus/prometheus-$PLATFORM.yml \
-storage.local.path=/prometheus \
-web.console.libraries=/etc/prometheus/console_libraries \
-web.console.templates=/etc/prometheus/consoles \
-web.listen-address=:$STATS_PORT
Loading

0 comments on commit 62b9d0a

Please sign in to comment.