<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by oguzozan on Medium]]></title>
        <description><![CDATA[Stories by oguzozan on Medium]]></description>
        <link>https://medium.com/@oguzozan92?source=rss-d43799ca566b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*myf8PJQO6VcUT_j-</url>
            <title>Stories by oguzozan on Medium</title>
            <link>https://medium.com/@oguzozan92?source=rss-d43799ca566b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:51:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oguzozan92/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Consul-Prometheus Monitoring Service Discovery]]></title>
            <link>https://medium.com/trendyol-tech/consul-prometheus-monitoring-service-discovery-7190bae50516?source=rss-d43799ca566b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7190bae50516</guid>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[consul]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[platform]]></category>
            <category><![CDATA[trendyol]]></category>
            <dc:creator><![CDATA[oguzozan]]></dc:creator>
            <pubDate>Wed, 06 May 2020 21:33:14 GMT</pubDate>
            <atom:updated>2020-05-06T21:33:14.515Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BnFU531tCg8vnvaSLDP4A.png" /></figure><p>Prometheus is one of the most popular monitoring tools. It stores the collected metrics in the time-series database. In Trendyol, we use prometheus for monitoring lots of services such as kubernetes, elasticsearch, couchbase, postgresql, kafka, rabbitmq.</p><p><strong>Exporters</strong></p><p>Most services expose “/metrics” endpoint for prometheus scrape jobs. For other services there are third-party exporters to collect metrics. Thus we can monitor our services end to end, by using prometheus. You can check the supported exporters the link below.</p><p><a href="https://prometheus.io/docs/instrumenting/exporters/">Exporters and integrations | Prometheus</a></p><p><strong>Configuration</strong></p><p>In Prometheus server, we need to specify targets(metric urls) in config file: “/etc/prometheus/prometheus.yaml ”<br>If you have an architecture consisting of thousands of servers and services, and this structure is constantly changing, <strong>you will have a huge configuration management challenge to monitor them. </strong>At this point, we face the need for <strong>dynamically changing configuration and automation.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jfJm623SSD1wqdz7.jpg" /></figure><p>After lots of researches and comparisons to overcome this challenge, we decided to use Consul Service Discovery to automate our monitoring systems.</p><p>You can check the detailed configuration document in the link below.</p><p><a href="https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config">Configuration</a></p><p>For example, to monitor an Elasticsearch service we need to install a node-exporter which serves at 9100 port as metric url and we need to modify the prometheus config file like this:</p><pre>- job_name: &#39;node&#39;<br>  metrics_path: /metrics<br>  static_configs:<br>    - targets: [&#39;10.0.0.1:9100&#39;]<br>      labels:<br>         _app:&#39;elasticsearch&#39;<br>         _service:&#39;node-exporter&#39;<br>         _hostname:&#39;Vm01&#39;<br>         _environment:&#39;dev&#39;<br>         _cluster:&#39;monitor-cls1&#39;<br>         _es_role:&#39;master&#39;<br>         _team:&#39;storefront&#39;</pre><p>In such use, we will need to update the targets when you add or remove each elasticsearch node. In fact, if you need to use a label structure as in the example, you may need to define a separate job for the whole elasticsearch node since each “_hostname” tag should be different.</p><p><strong>Let’s do the same process by creating a node-exporter service on the Consul.</strong></p><p><strong>Consul Service Creation</strong></p><p>You can register-deregister the services to your consul server <strong>with the consul agent</strong> you set up in the VMs <strong>or http api</strong> provided by Hashicorp’s Catalog Service.</p><p>You can reach the detailed document from the link below.</p><ul><li><a href="https://www.consul.io/docs/agent/services.html">Service Definition - Consul by HashiCorp</a></li><li><a href="https://www.consul.io/docs/agent/services.html">Service Definition - Consul by HashiCorp</a></li></ul><p>If there is a consul agent on your servers, it will be enough to save a json file under “/etc/consul/consul.d/” path as below and reload the consul-agent service.</p><pre>{<br> &quot;Service&quot;: {<br>  &quot;Address&quot;: &quot;10.0.0.1&quot;,<br>  &quot;ID&quot;: &quot;Vm01_NodeExporter&quot;,<br>  &quot;Name&quot;: &quot;node-exporter&quot;,<br>  &quot;Port&quot;: 9100,<br>  &quot;Tags&quot;: [<br>   &quot;_app=elasticsearch&quot;,<br>   &quot;_service=node-exporter&quot;,<br>   &quot;_hostname=Vm01&quot;,<br>   &quot;_environment=dev&quot;,<br>   &quot;_cluster=monitor-cls1&quot;,<br>   &quot;_es_role=master&quot;,<br>   &quot;_team=storefront&quot;<br>  ]<br> }<br>}</pre><p>As an additional option, you can remove the “Service” section and save it to your local computer with the json extension and create your service via http api provided by the consul catalog.</p><pre>curl -X PUT — data-binary @node-exporter.json <a href="http://10.250.216.165:8500/v1/agent/service/register">http://&lt;consul-server-ip:8500&gt;/v1/agent/service/register</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bX2ZtR-WncJ7yVwNWbkTJw.png" /></figure><p>While creating the consul service, we should define Consul tags according to our needs because we will export these Consul tags to Prometheus as labels. If we prepare Grafana dashboards using these labels, <strong>it will provide us a lot of flexibility.</strong></p><pre>- job_name: node-exporter<br>  scrape_interval: 15s<br>  honor_labels: true<br>  consul_sd_configs:<br>  - server: &lt;consulserver-ip&gt;:8500<br>    services: [node-exporter]<br>  relabel_configs:<br>  - source_labels: [__meta_consul_tags]<br>    regex: ^.*,_team=storefront,.*$<br>    action: keep<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_app=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _app<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_service=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _service<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_hostname=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _hostname<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_environment=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _environment<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_cluster=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _cluster<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_es_role=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _es_role<br>  - source_labels: [__meta_consul_tags]<br>    regex: .*,_team=([^,]+),.*<br>    replacement: ${1}<br>    target_label: _team</pre><p>One of the biggest advantages of using Consul is that we can filter by tag in prometheus. Let’s assume that there is a “node-exporter” service as in our example, this service can includes hundreds of instances from different teams. <strong>The filter feature will enable us to distribute a consul service with hundreds of instances to different Prometheus Servers according to a tag such as “_team”.</strong></p><p><strong>Conclusion</strong></p><p>As a result, with this structure, Prometheus can discover a service that we will create on the Consul and <strong>you can make the endpoints dynamic.</strong> Thus, when you create a VM, you can register it to consul according to the service it contains and automatically include it in your monitoring system. In addition, when you recycle this VM,it will be removed from the prometheus endpoints, due to it will be deregistered from the consul.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7190bae50516" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trendyol-tech/consul-prometheus-monitoring-service-discovery-7190bae50516">Consul-Prometheus Monitoring Service Discovery</a> was originally published in <a href="https://medium.com/trendyol-tech">Trendyol Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>