Skip to content

Commit c4621c3

Browse files
committed
Imported rubinius/influxdb-grafana to /metrics.
1 parent 2c284cc commit c4621c3

File tree

10 files changed

+2120
-0
lines changed

10 files changed

+2120
-0
lines changed

metrics/Dockerfile

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
FROM ubuntu:14.04
3+
4+
# statsd udp data (send rbx data to this port)
5+
EXPOSE 8125/udp
6+
# statsd management
7+
EXPOSE 8126
8+
# influxdb management UI
9+
EXPOSE 8083
10+
# influxdb API
11+
EXPOSE 8086
12+
# grafana dashboard UI
13+
EXPOSE 80
14+
15+
# Install some basic utilities with the OS package manager
16+
RUN apt-get update -y && apt-get upgrade -y
17+
RUN apt-get install -y wget curl python-pip supervisor nginx-light npm
18+
RUN pip install envtpl
19+
20+
# Install statsd and backend and configuration
21+
RUN npm -g install statsd
22+
RUN npm -g install statsd-influxdb-backend
23+
ADD statsd/config.js /statsd/config.js
24+
# Symbolic link because statsd expects a binary called `node`
25+
RUN ln -s /usr/bin/nodejs /usr/bin/node
26+
27+
# Install influxdb and setup script
28+
RUN wget http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb
29+
RUN dpkg -i influxdb_latest_amd64.deb
30+
ADD influxdb/setup.sh /influxdb/setup.sh
31+
# Set up influxdb and create the databases
32+
RUN influxdb/setup.sh
33+
34+
# Install grafana and configuration
35+
RUN mkdir /src
36+
RUN wget http://grafanarel.s3.amazonaws.com/grafana-1.9.0.tar.gz -O /src/grafana.tar.gz
37+
RUN cd /src && tar -xvf grafana.tar.gz && mv grafana-1.9.0 grafana
38+
ADD grafana/config.js.tpl /src/grafana/config.js.tpl
39+
ADD grafana/rbx-dash.json /src/grafana/app/dashboards/rbx-dash.json
40+
ADD grafana/setup.sh /src/grafana/setup.sh
41+
# Add nginx configuration
42+
ADD nginx/nginx.conf /etc/nginx/nginx.conf
43+
44+
# Add supervisord configuration and set default command for `docker run`
45+
ADD supervisord/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
46+
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

metrics/LICENSE

+363
Large diffs are not rendered by default.

metrics/README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
influxdb-grafana
2+
================
3+
4+
Docker container for using InfluxDB + Grafana to consume Rubinius Metrics StatsD output.
5+
6+
## Usage
7+
8+
1. **[Install docker](https://docs.docker.com/installation/)**.
9+
10+
2. **Run an instance of the container**. If this is the first time you're running it, docker will automatically download the stack of images that make up the container from [the automated build of this repository](https://registry.hub.docker.com/u/rubinius/influxdb-grafana/). The following command will run the container as a daemon (`-d`), mapping port `8125` of `localhost` to the container's `8125` statsd port, port `8086` of `localhost` to the container's `8086` influxdb query port, and port `80` of `localhost` to the container's `80` port serving the grafana interface. Depending on how docker is installed, you may need to run this command with `sudo`.
11+
12+
```shell
13+
docker run -d \
14+
-p 8125:8125/udp \
15+
-p 8086:8086 \
16+
-p 80:80 \
17+
rubinius/influxdb-grafana
18+
```
19+
20+
3. **Run your application** with Rubinius configured to output metrics to statsd at `localhost:8125`.
21+
22+
```shell
23+
RBXOPT="-Xsystem.metrics.target=statsd \
24+
-Xsystem.metrics.statsd.server=localhost:8125" \
25+
rbx # (your app here)
26+
```
27+
28+
4. **Open the dashboard** in your browser at `http://localhost:80`. The grafana dashboard will run in your browser, sending queries for data to influxdb at `http://localhost:8086`.
29+
30+
### Usage on Remote Hosts
31+
32+
The usage instructions above assume that the docker container is being run and exposing its ports on the same host as the browser. This is not likely to be true if you are running the container as a service to be connected to from other machines. In that case, you must be sure to replace `localhost` in the steps above with the host name or IP address running the container with the correct exposed or forwarded port.
33+
34+
As mentioned in step 4 above, grafana runs in your browser, sending queries for data to influxdb at `http://localhost:8086`. This also needs to be replaced with the correct remotely accessible address by passing an environment variable into the docker container. For example, if the remote address in your setup is is `rbx.myhost.com`, the docker container should be run on that host with the command:
35+
36+
```shell
37+
docker run -d \
38+
-p 8125:8125/udp \
39+
-p 8086:8086 \
40+
-p 80:80 \
41+
-e INFLUXDB_SERVER=http://rbx.myhost.com:8086 \
42+
rubinius/influxdb-grafana
43+
```
44+
45+
### Usage on Mac OS X
46+
47+
Because docker relies on features of the Linux kernel, it does not run containers natively in Mac OS X - it hosts containers inside of a Linux VM called `boot2docker`. One consequence of this is that the ports mapped to the docker host from containers are not mapped to `localhost` of OS X, but to the `boot2docker` host. Therefore, it must be treated like a 'remote host' using the steps outlined above, substituting `localhost` with the IP address given the command `boot2docker ip`. For example, if the `boot2docker ip` address in your setup is is `192.168.59.103`, the docker container could be run with the command:
48+
49+
```shell
50+
docker run -d \
51+
-p 8125:8125/udp \
52+
-p 8086:8086 \
53+
-p 80:80 \
54+
-e INFLUXDB_SERVER=http://192.168.59.103:8086 \
55+
rubinius/influxdb-grafana
56+
```

metrics/grafana/config.js.tpl

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
2+
define(['settings'], function(Settings) {
3+
return new Settings({
4+
5+
/* Data sources
6+
* ========================================================
7+
* Datasources are used to fetch metrics, annotations, and serve as dashboard storage
8+
* - You can have multiple of the same type.
9+
* - grafanaDB: true marks it for use for dashboard storage
10+
* - default: true marks the datasource as the default metric source (if you have multiple)
11+
* - basic authentication: use url syntax http://username:password@domain:port
12+
*/
13+
14+
// InfluxDB example setup (the InfluxDB databases specified need to exist)
15+
datasources: {
16+
rbx: {
17+
type: 'influxdb',
18+
url: "{{ INFLUXDB_SERVER | default("http://localhost:8086") }}/db/rbx",
19+
username: 'root',
20+
password: 'root',
21+
},
22+
grafana: {
23+
type: 'influxdb',
24+
url: "{{ INFLUXDB_SERVER | default("http://localhost:8086") }}/db/grafana",
25+
username: 'root',
26+
password: 'root',
27+
grafanaDB: true
28+
},
29+
},
30+
31+
/* Global configuration options
32+
* ========================================================
33+
*/
34+
35+
// specify the limit for dashboard search results
36+
search: {
37+
max_results: 100
38+
},
39+
40+
// default home dashboard
41+
default_route: '/dashboard/file/rbx-dash.json',
42+
43+
// set to false to disable unsaved changes warning
44+
unsaved_changes_warning: true,
45+
46+
// set the default timespan for the playlist feature
47+
// Example: "1m", "1h"
48+
playlist_timespan: "1m",
49+
50+
// If you want to specify password before saving, please specify it below
51+
// The purpose of this password is not security, but to stop some users from accidentally changing dashboards
52+
admin: {
53+
password: ''
54+
},
55+
56+
// Change window title prefix from 'Grafana - <dashboard title>'
57+
window_title_prefix: 'RBX Dashboard - ',
58+
59+
// Add your own custom panels
60+
plugins: {
61+
// list of plugin panels
62+
panels: [],
63+
// requirejs modules in plugins folder that should be loaded
64+
// for example custom datasources
65+
dependencies: [],
66+
}
67+
});
68+
});

0 commit comments

Comments
 (0)