Skip to content

Instantly share code, notes, and snippets.

@heyawhite
Last active December 18, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heyawhite/d87bf9bdb054c8519ae42978454b4887 to your computer and use it in GitHub Desktop.
Save heyawhite/d87bf9bdb054c8519ae42978454b4887 to your computer and use it in GitHub Desktop.
Create an Ubuntu infrastructure sandbox and add Docker tools

Create a Prometheus instance within an infrastructure container

Get into your Triton environment

$ eval "$(triton env)"

Create an ubuntu infrastructure container

$ triton instance create -w --name=ubuntu-docker ubuntu-16.04 g4-highcpu-128M

Get the instance IP address

$ triton inst get ubuntu-docker

SSH into the container

$ ssh root@<Primary IP address>

Download Docker & CLI tools

Download Triton & Docker (along with Triton-Docker and Triton-Compose) into the container. Follow these commands (source https://github.com/misterbisson/triton-sandbox/blob/b46116166db4ec053f8a2e330e13b30e8a754171/Dockerfile)

$ apt-get update && apt-get install -y --no-install-recommends \
        apt-transport-https \
        ca-certificates \
        curl \
        dnsutils \
        git \
        htop \
        less \
        nodejs \
        npm \
        ssh \
        unzip \
        vim
$ rm -rf /var/lib/apt/lists/*
$ ln -s /usr/bin/nodejs /usr/bin/node
$ npm install -g triton manta json
$ curl -o /usr/local/bin/triton-docker https://raw.githubusercontent.com/joyent/triton-docker-cli/master/triton-docker
$ chmod +x /usr/local/bin/triton-docker
$ ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-compose
$ ln -Fs /usr/local/bin/triton-docker /usr/local/bin/triton-docker-install
$ ln -Fs /usr/local/bin/triton-docker-helper /usr/local/bin/docker
$ ln -Fs /usr/local/bin/triton-compose-helper /usr/local/bin/docker-compose
$ /usr/local/bin/triton-docker-install

Add Autopilot Pattern Prometheus to container

$ mkdir /demo
$ cd /demo
$ git clone https://github.com/autopilotpattern/prometheus.git

Set up Triton

You must set up your Triton profiles and environment variables to actually spin up any containers.

  1. Create and add an SSH key to your account, from within Ubuntu: https://docs.joyent.com/public-cloud/getting-started
  2. Create your Triton profiles: https://docs.joyent.com/public-cloud/api-access/cloudapi#configuration
  3. Add ENV variables: https://docs.joyent.com/public-cloud/api-access/cloudapi#environment-variables
  4. Get into your triton environment: eval "$(triton env <profile>)"

Set up Prometheus

Get into the Triton Prometheus example folder: cd /demo/prometheus/examples/triton

Run ./setup.sh

Run triton-compose up -d for your consul and prometheus containers.

$ triton-compose up -d
Creating triton_prometheus_1
Creating triton_consul_1

Get the IP address for Prometheus

You'll need the Prometheus instance IP address to get the Telemetry:

$ triton inst get triton_prometheus_1
{
    "id": "35202bf8-e7c0-e542-adb2-af7ed1cd8a6e",
    "name": "triton_prometheus_1",
    "type": "smartmachine",
    "brand": "lx",
    "state": "running",
    "image": "ef867ef5-0a79-8c0e-1eb2-777a0672ea14",
    [...]
    "primaryIp": "165.222.222.222",
    [...]
}

Connect to it in your browser at: http://165.222.222.222:9090

Setup Grafana

Grafana provides a simple and easy way to graph/plot time series information, and supports reading from prometheus out of the box.

To install, you can use the official Grafana image:

$ triton-docker run -d -P --name my-grafana grafana/grafana
Unable to find image 'grafana/grafana:latest' locally
latest: Pulling from grafana/grafana (req fc2b6572-ee84-4676-b2d0-1e087ed4e57e)
c20dc0c5afeb: Already exists 
75979c2134af: Pull complete 
603f014de07f: Pull complete 
Digest: sha256:3572b4b9f083259c8af458d6c31d4eafb1a7d99c9a931a47e101aabc2ad6663b
Status: Downloaded newer image for grafana/grafana:latest

Then you can connect to the Grafana port (3000) on the image. First, get your instance IP address:

$ triton inst get my-grafana
{
    "id": "c1c61dc8-f102-694d-d5fe-e80fff5e1dd9",
    "name": "my-grafana",
    "type": "smartmachine",
    "brand": "lx",
    "state": "running",
    "image": "9ef43de1-3f14-0f64-b6a6-05656b863dd3",
    [...]
    "primaryIp": "165.111.111.111",
    [...]
}

In your browser, open the primary IP address connected to port 3000. For example: http://165.111.111.111:3000

The default username and password to login are admin/admin.

Add data sources

From the home dashboard, under Getting Started with Grafana, select Create your first datasource. Add Prometheus as your data source:

  • Name your data source Prometheus
  • Select the type of source as Prometheus
  • Under HTTP settings, enter the URL as seen in Get the IP address for Prometheus.
  • Click Add to confirm this data source.

Once the data source was successfully added, scroll to the top and select Dashboards. Import the Prometheus data.

Upload data center scraper JSON file

From the dashboard, select New Dashboard > Import Dashboard.

Copy the content from the sandbox-get-all-data.json file into the text box under Or paste JSON. Click Load.

This will create a new dashboard to see metrics for every container on the data center shared with Prometheus.

Once imported, to view your stats visit Home and click the Triton dashboard. It will be located at a URL similar to: http://165.111.111.111:3000/dashboard/db/triton?refresh=5m&orgId=1

{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
],
"__requires": [
{
"type": "grafana",
"id": "grafana",
"name": "Grafana",
"version": "4.1.2"
},
{
"type": "panel",
"id": "graph",
"name": "Graph",
"version": ""
},
{
"type": "datasource",
"id": "prometheus",
"name": "Prometheus",
"version": "1.0.0"
}
],
"annotations": {
"list": []
},
"description": "Triton metrics",
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": null,
"links": [],
"refresh": "5m",
"rows": [
{
"collapse": false,
"height": -152,
"panels": [
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"description": "(user + system time)",
"fill": 1,
"height": "500px",
"id": 1,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": "avg",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((increase(cpu_sys_usage[60s]) + increase(cpu_user_usage[60s])) / 60000000000)",
"intervalFactor": 1,
"refId": "A",
"step": 15
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "CPU Utilization",
"tooltip": {
"shared": false,
"sort": 2,
"value_type": "individual"
},
"transparent": false,
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "percentunit",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "s",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"height": "500px",
"id": 4,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": null,
"sortDesc": null,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((increase(net_agg_bytes_in[60s])) / 1000) / 60",
"intervalFactor": 1,
"refId": "A",
"step": 30
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Network Ingress",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"transparent": true,
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "KBs",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "s",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"height": "500px",
"id": 5,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((increase(net_agg_bytes_out[60s])) / 1000) / 60",
"intervalFactor": 2,
"refId": "A",
"step": 60
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Network Egress",
"tooltip": {
"shared": true,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "KBs",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "s",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
},
{
"collapse": false,
"height": 298,
"panels": [
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"height": "500px",
"id": 3,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 12,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((zfs_used / 1000) / 1000) / 1000",
"intervalFactor": 2,
"refId": "A",
"step": 30
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "ZFS Allocated Space",
"tooltip": {
"shared": false,
"sort": 2,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decgbytes",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
},
{
"collapse": false,
"height": -272,
"panels": [
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"height": "500px",
"id": 2,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"rightSide": false,
"show": true,
"sort": "avg",
"sortDesc": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((mem_agg_usage / 1000) / 1000) / 1000",
"intervalFactor": 1,
"refId": "A",
"step": 30
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "DRAM Allocated",
"tooltip": {
"shared": false,
"sort": 1,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decgbytes",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "s",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"aliasColors": {},
"bars": false,
"datasource": "${DS_PROMETHEUS}",
"fill": 1,
"height": "500px",
"id": 6,
"legend": {
"alignAsTable": true,
"avg": true,
"current": true,
"max": true,
"min": true,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "((mem_swap / 1000) / 1000)",
"intervalFactor": 2,
"legendFormat": "",
"refId": "A",
"step": 60
}
],
"thresholds": [],
"timeFrom": null,
"timeShift": null,
"title": "Swap",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "decmbytes",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "s",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
}
],
"repeat": null,
"repeatIteration": null,
"repeatRowId": null,
"showTitle": false,
"title": "Dashboard Row",
"titleSize": "h6"
}
],
"schemaVersion": 14,
"style": "dark",
"tags": [
"pnw1",
"triton",
"admin"
],
"templating": {
"list": []
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "utc",
"title": "Triton",
"version": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment