Skip to content

Commit

Permalink
commit 350c68c
Browse files Browse the repository at this point in the history
Merge: a94cb2f 884a44a
Author: Thomas Boerger <[email protected]>
Date:   Sun Oct 7 19:59:56 2018 +0200

    Merge pull request #1 from promhippie/add-docs

    Add basic documentation and build instructions
  • Loading branch information
tboerger committed Oct 7, 2018
1 parent acde5bb commit dedf182
Show file tree
Hide file tree
Showing 5 changed files with 201 additions and 44 deletions.
165 changes: 137 additions & 28 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<meta name="description" content="Prometheus service discovery for Scaleway">
<meta name="author" content="Thomas Boerger">

<style type="text/css">
<link rel="stylesheet" href="syntax.css" />

<style type="text/css">
body,
div,
dl,
Expand Down Expand Up @@ -163,13 +165,12 @@
color: #d54e21;
}

code,
cite {
background-color: #F0F2F4;
border-radius: 3px;
color: #000;
font: monospace;
padding: 2px 7px;
.highlight pre {
padding: 10px;
}

.highlight {
margin-bottom: 4%;
}

a {
Expand Down Expand Up @@ -227,6 +228,14 @@
column-gap: 20px;
}

dl dt {
font-weight: bold;
}

dl dd {
padding-left: 10px;
}

@media screen and (min-width: 500px) {
ul.col-2 {
-webkit-column-count: 3;
Expand Down Expand Up @@ -362,10 +371,6 @@ <h1>
Getting Started
</a>

<a href="#usage">
Usage
</a>

<a href="#building">
Building
</a>
Expand Down Expand Up @@ -393,24 +398,108 @@ <h1>

<h2 id="installation">Installation</h2>

<h2 id="configuration">Configuration</h2>
<p>We won&rsquo;t cover further details how to properly setup <a href="https://prometheus.io">Prometheus</a> itself, we will only cover some basic setup based on <a href="https://docs.docker.com/compose/">docker-compose</a>. But if you want to run this service discovery without <a href="https://docs.docker.com/compose/">docker-compose</a> you should be able to adopt that to your needs.</p>

</section>

<section id="usage">
<h1>
<a href="#usage">
Usage
</a>
<p>First of all we need to prepare a configuration for <a href="https://prometheus.io">Prometheus</a> that includes the service discovery which simply maps to a node exporter.</p>

<small>
<a href="#html">
Back to Top
</a>
</small>
</h1>
<script src="//gist.github.com/tboerger/4f445d609f0894a5fe40c20e7a42d565.js?file=prometheus.yml"></script>

<p>After preparing the configuration we need to create the <code>docker-compose.yml</code> within the same folder, this <code>docker-compose.yml</code> starts a simple <a href="https://prometheus.io">Prometheus</a> instance together with the service discovery. Don&rsquo;t forget to update the envrionment variables with the required credentials. If you are using a different volume for the service discovery you have to make sure that the container user is allowed to write to this volume.</p>

<script src="//gist.github.com/tboerger/4f445d609f0894a5fe40c20e7a42d565.js?file=docker-compose.yml"></script>

<p>Since our <code>latest</code> Docker tag always refers to the <code>master</code> branch of the Git repository you should always use some fixed version. You can see all available tags at our <a href="https://hub.docker.com/r/promhippie/prometheus-scw-sd/tags/">DockerHub repository</a>, there you will see that we also provide a manifest, you can easily start the exporter on various architectures without any change to the image name. You should apply a change like this to the <code>docker-compose.yml</code>:</p>

<script src="//gist.github.com/tboerger/4f445d609f0894a5fe40c20e7a42d565.js?file=tag.diff"></script>

<p>Finally the service discovery should be configured fine, let&rsquo;s start this stack with <a href="https://docs.docker.com/compose/">docker-compose</a>, you just need to execute <code>docker-compose up</code> within the directory where you have stored <code>prometheus.yml</code> and <code>docker-compose.yml</code>.</p>

<script src="//gist.github.com/tboerger/4f445d609f0894a5fe40c20e7a42d565.js?file=output.log"></script>

<p>That&rsquo;s all, the service discovery should be up and running. You can access <a href="https://prometheus.io">Prometheus</a> at <a href="http://localhost:9090">http://localhost:9090</a>.</p>

<figure>

<img src="service-discovery.png" />


<figcaption>
<h4>Prometheus service discovery for Hetzner</h4>

</figcaption>

</figure>

<h2 id="kubernetes">Kubernetes</h2>

<p>Currently we have not prepared a deployment for Kubernetes, but this is something we will provide for sure. Most interesting will be the integration into the <a href="https://coreos.com/operators/prometheus/docs/latest/">Prometheus Operator</a>, so stay tuned.</p>

<h2 id="configuration">Configuration</h2>

<dl>
<dt>PROMETHEUS_SCW_TOKEN<br /></dt>
<dd>Access token for the Scaleway API, required for authentication<br />
<br /></dd>
<dt>PROMETHEUS_SCW_ORG<br /></dt>
<dd>Organization for the Scaleway API, required for authentication<br />
<br /></dd>
<dt>PROMETHEUS_SCW_REGION<br /></dt>
<dd>Region for the Scaleway API, required for authentication<br />
<br /></dd>
<dt>PROMETHEUS_SCW_LOG_LEVEL<br /></dt>
<dd>Only log messages with given severity, defaults to <code>info</code><br />
<br /></dd>
<dt>PROMETHEUS_SCW_LOG_PRETTY<br /></dt>
<dd>Enable pretty messages for logging, defaults to <code>true</code><br />
<br /></dd>
<dt>PROMETHEUS_SCW_WEB_ADDRESS<br /></dt>
<dd>Address to bind the metrics server, defaults to <code>0.0.0.0:9000</code><br />
<br /></dd>
<dt>PROMETHEUS_SCW_WEB_PATH<br /></dt>
<dd>Path to bind the metrics server, defaults to <code>/metrics</code><br />
<br /></dd>
<dt>PROMETHEUS_SCW_OUTPUT_FILE<br /></dt>
<dd>Path to write the file_sd config, defaults to <code>/etc/prometheus/scw.json</code><br />
<br /></dd>
<dt>PROMETHEUS_SCW_OUTPUT_REFRESH<br /></dt>
<dd>Discovery refresh interval in seconds, defaults to <code>30</code><br />
<br /></dd>
</dl>

<h2 id="labels">Labels</h2>

<ul>
<li><code>__meta_scaleway_name</code><br /></li>
<li><code>__meta_scaleway_id</code><br /></li>
<li><code>__meta_scaleway_arch</code><br /></li>
<li><code>__meta_scaleway_image_id</code><br /></li>
<li><code>__meta_scaleway_image_name</code><br /></li>
<li><code>__meta_scaleway_public_ipv4</code><br /></li>
<li><code>__meta_scaleway_state</code><br /></li>
<li><code>__meta_scaleway_private_ipv4</code><br /></li>
<li><code>__meta_scaleway_hostname</code><br /></li>
<li><code>__meta_scaleway_org</code><br /></li>
<li><code>__meta_scaleway_commercial_type</code><br /></li>
<li><code>__meta_scaleway_platform</code><br /></li>
<li><code>__meta_scaleway_hypervisor</code><br /></li>
<li><code>__meta_scaleway_node</code><br /></li>
<li><code>__meta_scaleway_blade</code><br /></li>
<li><code>__meta_scaleway_chassis</code><br /></li>
<li><code>__meta_scaleway_cluster</code><br /></li>
<li><code>__meta_scaleway_zone</code><br />
<br /></li>
</ul>

<h2 id="metrics">Metrics</h2>

<dl>
<dt>prometheus_scw_sd_request_duration_seconds<br /></dt>
<dd>Histogram of latencies for requests to the Scaleway API<br />
<br /></dd>
<dt>prometheus_scw_sd_request_failures_total<br /></dt>
<dd>Total number of failed requests to the Scaleway API<br /></dd>
</dl>


</section>

<section id="building">
Expand All @@ -426,7 +515,27 @@ <h1>
</small>
</h1>


<p>As this project is built with Go you need to install Go first. The installation of Go is out of the scope of this document, please follow the <a href="https://golang.org/doc/install">official documentation</a>. After the installation of Go you need to get the sources:</p>

<div class="highlight"><pre class="chroma"><code class="language-txt" data-lang="txt">go get -d github<span class="p">.</span><span class="s">com/promhippie/prometheus-scw-sd
</span><span class="s"></span>cd <span class="err">$</span>GOPATH/src/github<span class="p">.</span>com/promhippie/prometheus-scw-sd</code></pre></div>

<p>All required tool besides Go itself are bundled or getting automatically installed within the <code>GOPATH</code>. We are using <a href="https://github.com/twitchtv/retool">retool</a> to keep the used tools consistent and <a href="https://github.com/golang/dep">dep</a> to manage the dependencies. All commands to build this project are part of our <code>Makefile</code>.</p>

<div class="highlight"><pre class="chroma"><code class="language-txt" data-lang="txt"><span class="c"># install retool</span>
make retool

<span class="c"># sync dependencies</span>
make sync

<span class="c"># generate code</span>
make generate

<span class="c"># build binary</span>
make build</code></pre></div>

<p>Finally you should have the binary within the <code>bin/</code> folder now, give it a try with <code>./bin/prometheus-scw-sd -h</code> to see all available options.</p>

</section>

<section id="license">
Expand Down
16 changes: 5 additions & 11 deletions index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,9 @@
<pubDate>Wed, 02 May 2018 00:00:00 +0000</pubDate>

<guid>https://promhippie.github.io/prometheus-scw-sd/getting-started/</guid>
<description> Installation Configuration </description>
</item>

<item>
<title>Usage</title>
<link>https://promhippie.github.io/prometheus-scw-sd/usage/</link>
<pubDate>Wed, 02 May 2018 00:00:00 +0000</pubDate>

<guid>https://promhippie.github.io/prometheus-scw-sd/usage/</guid>
<description></description>
<description>Installation We won&amp;rsquo;t cover further details how to properly setup Prometheus itself, we will only cover some basic setup based on docker-compose. But if you want to run this service discovery without docker-compose you should be able to adopt that to your needs.
First of all we need to prepare a configuration for Prometheus that includes the service discovery which simply maps to a node exporter.
After preparing the configuration we need to create the docker-compose.</description>
</item>

<item>
Expand All @@ -35,7 +28,8 @@
<pubDate>Wed, 02 May 2018 00:00:00 +0000</pubDate>

<guid>https://promhippie.github.io/prometheus-scw-sd/building/</guid>
<description></description>
<description>As this project is built with Go you need to install Go first. The installation of Go is out of the scope of this document, please follow the official documentation. After the installation of Go you need to get the sources:
go get -d github.com/promhippie/prometheus-scw-sd cd $GOPATH/src/github.com/promhippie/prometheus-scw-sd All required tool besides Go itself are bundled or getting automatically installed within the GOPATH. We are using retool to keep the used tools consistent and dep to manage the dependencies.</description>
</item>

<item>
Expand Down
Binary file added service-discovery.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<lastmod>2018-05-02T00:00:00+00:00</lastmod>
</url>

<url>
<loc>https://promhippie.github.io/prometheus-scw-sd/usage/</loc>
<lastmod>2018-05-02T00:00:00+00:00</lastmod>
</url>

<url>
<loc>https://promhippie.github.io/prometheus-scw-sd/building/</loc>
<lastmod>2018-05-02T00:00:00+00:00</lastmod>
Expand Down
59 changes: 59 additions & 0 deletions syntax.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Background */ .chroma { color: #f8f8f2; background-color: #272822 }
/* Error */ .chroma .err { color: #960050; background-color: #1e0010 }
/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; }
/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; width: auto; overflow: auto; display: block; }
/* LineHighlight */ .chroma .hl { display: block; width: 100%;background-color: #ffffcc }
/* LineNumbersTable */ .chroma .lnt { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* LineNumbers */ .chroma .ln { margin-right: 0.4em; padding: 0 0.4em 0 0.4em; }
/* Keyword */ .chroma .k { color: #66d9ef }
/* KeywordConstant */ .chroma .kc { color: #66d9ef }
/* KeywordDeclaration */ .chroma .kd { color: #66d9ef }
/* KeywordNamespace */ .chroma .kn { color: #f92672 }
/* KeywordPseudo */ .chroma .kp { color: #66d9ef }
/* KeywordReserved */ .chroma .kr { color: #66d9ef }
/* KeywordType */ .chroma .kt { color: #66d9ef }
/* NameAttribute */ .chroma .na { color: #a6e22e }
/* NameClass */ .chroma .nc { color: #a6e22e }
/* NameConstant */ .chroma .no { color: #66d9ef }
/* NameDecorator */ .chroma .nd { color: #a6e22e }
/* NameException */ .chroma .ne { color: #a6e22e }
/* NameFunction */ .chroma .nf { color: #a6e22e }
/* NameOther */ .chroma .nx { color: #a6e22e }
/* NameTag */ .chroma .nt { color: #f92672 }
/* Literal */ .chroma .l { color: #ae81ff }
/* LiteralDate */ .chroma .ld { color: #e6db74 }
/* LiteralString */ .chroma .s { color: #e6db74 }
/* LiteralStringAffix */ .chroma .sa { color: #e6db74 }
/* LiteralStringBacktick */ .chroma .sb { color: #e6db74 }
/* LiteralStringChar */ .chroma .sc { color: #e6db74 }
/* LiteralStringDelimiter */ .chroma .dl { color: #e6db74 }
/* LiteralStringDoc */ .chroma .sd { color: #e6db74 }
/* LiteralStringDouble */ .chroma .s2 { color: #e6db74 }
/* LiteralStringEscape */ .chroma .se { color: #ae81ff }
/* LiteralStringHeredoc */ .chroma .sh { color: #e6db74 }
/* LiteralStringInterpol */ .chroma .si { color: #e6db74 }
/* LiteralStringOther */ .chroma .sx { color: #e6db74 }
/* LiteralStringRegex */ .chroma .sr { color: #e6db74 }
/* LiteralStringSingle */ .chroma .s1 { color: #e6db74 }
/* LiteralStringSymbol */ .chroma .ss { color: #e6db74 }
/* LiteralNumber */ .chroma .m { color: #ae81ff }
/* LiteralNumberBin */ .chroma .mb { color: #ae81ff }
/* LiteralNumberFloat */ .chroma .mf { color: #ae81ff }
/* LiteralNumberHex */ .chroma .mh { color: #ae81ff }
/* LiteralNumberInteger */ .chroma .mi { color: #ae81ff }
/* LiteralNumberIntegerLong */ .chroma .il { color: #ae81ff }
/* LiteralNumberOct */ .chroma .mo { color: #ae81ff }
/* Operator */ .chroma .o { color: #f92672 }
/* OperatorWord */ .chroma .ow { color: #f92672 }
/* Comment */ .chroma .c { color: #75715e }
/* CommentHashbang */ .chroma .ch { color: #75715e }
/* CommentMultiline */ .chroma .cm { color: #75715e }
/* CommentSingle */ .chroma .c1 { color: #75715e }
/* CommentSpecial */ .chroma .cs { color: #75715e }
/* CommentPreproc */ .chroma .cp { color: #75715e }
/* CommentPreprocFile */ .chroma .cpf { color: #75715e }
/* GenericDeleted */ .chroma .gd { color: #f92672 }
/* GenericEmph */ .chroma .ge { font-style: italic }
/* GenericInserted */ .chroma .gi { color: #a6e22e }
/* GenericStrong */ .chroma .gs { font-weight: bold }
/* GenericSubheading */ .chroma .gu { color: #75715e }

0 comments on commit dedf182

Please sign in to comment.