<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>observability Archives | Clever Cloud</title>
	<atom:link href="https://www.clever.cloud/blog/tag/observability/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.clever.cloud/blog/tag/observability/</link>
	<description>From Code to Product</description>
	<lastBuildDate>Thu, 27 Nov 2025 15:28:15 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://cdn.clever-cloud.com/uploads/2023/03/cropped-cropped-favicon-32x32.png</url>
	<title>observability Archives | Clever Cloud</title>
	<link>https://www.clever.cloud/blog/tag/observability/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>GlitchTip on Clever Cloud, a Sentry alternative</title>
		<link>https://www.clever.cloud/blog/features/2022/06/21/glitchtip-on-clever-cloud-a-sentry-alternative/</link>
		
		<dc:creator><![CDATA[Aurélien Hebert]]></dc:creator>
		<pubDate>Tue, 21 Jun 2022 15:13:11 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[logs]]></category>
		<category><![CDATA[observability]]></category>
		<guid isPermaLink="false">https://www.clever-cloud.com/?p=6478</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2022/06/glitchtip.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="glitchtip" decoding="async" fetchpriority="high" srcset="https://cdn.clever-cloud.com/uploads/2022/06/glitchtip.png 1400w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph -->
<p>At Clever Cloud, we like to have some context about our application status and logs. That's why we have a lot of tools deployed to gain some observability. A lot of them are freely available for our customers (a log view, a metrics view or Grafana). Still, there are some tools that we use internally that could be helpful to many. We discovered recently <a href="https://glitchtip.com/" target="_blank" rel="noreferrer noopener">glichtip</a>, which is an open source error tracking. Glichtip is a great alternative to Sentry and less complex to deploy. We will add that Glichtip is compatible with the <a href="https://docs.sentry.io/platforms/">Sentry's open source SDK</a>.  </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Context</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We used Sentry to analyse the errors coming from our own application logs. We were still using the <code>9.1</code> version until we had too many trouble to keep it running. We then had to upgrade or find a new solution. All Sentry version post <code>9.1</code> require many more components to deploy (as Kafka, Snuba or Clickhouse). This is still possible to deploy it with a <a href="https://develop.sentry.dev/self-hosted/">self hosted script</a>. We wanted every component to be standalone outside of the main Sentry application, it meant that we had to provide authentication to all components. It was not a big issue, but it took us more time that what we first expected. And at the same time, we discovered a new project: Glitchtip. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Glitchtip</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>All started by a French <a href="https://twitter.com/aeris22/status/1516411508225417228?t=EdjijoImwBdKwOjI63m5-A&amp;s=19">tweet</a>, about the discovery of a new tool: <a href="https://glitchtip.com/">Glitchtip</a>. This tweet said that Glitchtip is compatible to Sentry, free and easy to self host it, so it was evident that we were going to give it a try.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>What does Glitchtip provide? Inside your application, with the Sentry SDK, you will transfer some of your error logs. Then the tool help you to track those errors, to better understand when a new version tool creates new errors,  organize or search them... In a quick word, it's a very useful tool to debug your deployed software. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Clever Cloud deploy </h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Setup</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>First, we will download Glitchtip <code>Docker</code> project and customize it a bit to match how docker applications are run in Clever Cloud.</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Get latest Glitchtip release
git clone https://gitlab.com/glitchtip/glitchtip.git

# Go to the folder
cd glitchtip
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Then open your favorite code IDE and open the <code>Dockerfile</code>: </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Remove
FROM glitchtip/glitchtip:latest

# And add instead:
FROM glitchtip/glitchtip:v1.12.2

COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Here we will set-up the last Glitchtip release. When we were writing this blog it was the <code>v1.12.2</code>. You can find them <a href="https://hub.docker.com/r/glitchtip/glitchtip/tags">here</a>. We set up a new script to use <code>docker-entrypoint.sh</code> which will enable us to start or the Glitchtip web application or the Glitchtip worker. The <code>docker-entrypoint.sh</code> should contain the following script:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># docker-entrypoint.sh script:
#!/bin/bash

if [ "${START_TARGET}" = "worker" ]; then
  mkdir /tmp/sandboxed
	cd /tmp/sandboxed &amp;&amp; nohup python -m http.server 8080 &amp;
	/code/bin/run-celery-with-beat.sh
else
  /code/bin/start.sh
fi

# Don't forget to make it executable:
chmod u+x docker-entrypoint.sh
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Glitchtip comes with a <code>Dockerfile</code>, which means we will use a <a href="https://www.clever.cloud/developers/deploy/application/java/java-jar/">a docker runtime</a>. It also requires a <a href="https://www.postgresql.org/">PostgreSQL Database</a> and <a href="https://redis.io/">a Redis cache</a>, which means we will deploy a <a href="https://www.clever.cloud/developers/doc/addons/postgresql/">PostgreSQL</a><a href="https://www.clever.cloud/developers/deploy/addon/postgresql/postgresql/"> addon</a> and a <a href="https://www.clever.cloud/developers/doc/addons/redis/">Redis addon.</a> Adding a <code>-o</code> option in all <code>create</code> command line can be used to specify which organisation to use.</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Create the docker applications:
clever create --type docker glitchtip-web
clever create --type docker glitchtip-worker

# Create the PG addon
clever addon create postgresql-addon --plan s_sml --addon-version 14 glitchtip-postgres

# Link the addon
clever service link-addon glitchtip-postgres -a glitchtip-web
clever service link-addon glitchtip-postgres -a glitchtip-worker

# Create the Redis addon
clever addon create redis-addon --plan s_mono glitchtip-redis

# Link the addon
clever service link-addon glitchtip-redis -a glitchtip-web
clever service link-addon glitchtip-redis -a glitchtip-worker
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Config</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For now we will configure Glitchtip through environment variables. As we use several applications, let's deploy an addon configuration provider. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Create a config addon:
clever addon create config-provider --plan std glitchtip-config

# Link the addon
clever service link-addon glitchtip-config -a glitchtip-web
clever service link-addon glitchtip-config -a glitchtip-worker

</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Now that we have deployed a config addon provider let's update its configuration. To do it go to the Clever Cloud console and then select the <code>glitchtip-config</code>. In the variable panel, select the <code>expert</code> mode and add the following required variable, (fill their value based on the provided commentary):</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># In the config addon provider add:
CC_DOCKER_EXPOSED_HTTP_PORT="8080"
# Copy paste here the POSTGRESQL_ADDON_URI environment variable of the glitchtip-postgres addon 
DATABASE_URL="postgresql://user:password@host:port/database"
# Provide a valid email server
EMAIL_URL="smtp://email:password@smtp_url:port"
# Copy paste here the application domain name of the glitchtip-web application instead (should look like: https://app-da7a7a7a-da7a-4242-7a7a-da7a42427a7a.cleverapps.io)
GLITCHTIP_DOMAIN="MY_APP_DOMAIN_NAME"
# Copy paste here the REDIS_ADDON's environment variable of the glitchtip-redis addon 
REDIS_HOST= &lt; REDIS_HOST &gt;
REDIS_PASSWORD= &lt; REDIS_PASSWORD &gt; 
REDIS_PORT= &lt; REDIS_PORT &gt;
# Generate your own custom secret key for Glitchtip
SECRET_KEY= &lt; choose a secret key &gt;
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Note that you can find more information about how to configure Glitchtip in its <a href="https://glitchtip.com/documentation/install#configuration">documentation</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Each docker application requires some custom configuration too:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash">#glitchtip-web custom env
clever env set CC_RUN_SUCCEEDED_HOOK "./manage.py migrate" -a glitchtip-web
clever env set START_TARGET "web" -a glitchtip-web
#glitchtip-worker custom env
clever env set START_TARGET "worker" -a glitchtip-worker
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy and run</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Now that everything is set, it's time to deploy and run your Glitchtip application. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Remove initial git
rm -r .git 

# Init a git repository
git init

# Add your files
git add .

# Commit the changes
git commit -m "clever init and deploy"

# Deploy the application
clever deploy -a glitchtip-web
clever deploy -a glitchtip-worker

# Open Glitchtip in your browser
clever open -a glitchtip-web
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Your glitchtip is now almost ready to use. One last action is required: you need to create a super user to administrate Glitchtip. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Connect in SSH to your Clever application:
clever ssh -a glitchtip-web

# Run 
./manage.py createsuperuser
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Great job! You should now have an access to glitchtip admin page (available on your application /admin path). You can then create users or connect to your favorite social application to authenticate your users. You will find more information on the <a href="https://glitchtip.com/documentation/install#django-admin">documentation</a>. You can set your <a href="https://www.clever.cloud/blog/fonctionnalites/2022/05/11/how-to-deploy-keycloak-on-clever-cloud/">own keycloak on Clever Cloud</a> and use it to connect to Glitchtip! </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Connect Glitchtip to an application</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We will reuse the akka application example we used for our <a href="https://www.clever.cloud/blog/fonctionnalites">scala exemple blogpost</a>. And we will then see how we can forward our own error logs to Glitchtip.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Create a Glitchtip project</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The first step will be to login with new root user (or any Glitchtip user you created or linked with a social application). Glitchtip will ask you to create your organisation. In our case let's set <code>clever-cloud</code>. As we want to monitore our application error's logs, we will need to create a new project directly in Glitchtip UI. Let's call it "myakka" and create it's associated "Scala-dev" team. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Once this project is create you will be able to get a <code>DSN</code>. We will load it later as environment variable for the akka application. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Create a Glitchtip Token </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Go to <code>Profile/auth token</code> and craft a new glitchtip token with at least the following project rights: read, write and releases. Save it for later.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Setup the AKKA example application on Clever Cloud</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The first step will be to deploy AKKA example application on Clever Cloud as mentionned in the <a href="https://www.clever.cloud/blog/fonctionnalites">scala exemple blogpost</a>. <a href="https://github.com/CleverCloud/scala-akka-http-postgres-example" target="_blank" rel="noreferrer noopener">Clone</a> the project and instead of the main branch, use the <code>blogpost-sentry</code> one. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Clone Clever Cloud akka example project:
git clone https://github.com/CleverCloud/scala-akka-http-postgres-example.git

# Checkout blogpost-sentry
git checkout blogpost-sentry
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>In this branch, we update a bit the application to connect it to Sentry. Then we send only the starting server HTTP logs with a custom status tag (success or failure). This is code we use in the <code>blogpost-sentry</code> branch:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Register Sentry
Sentry.init(sentryConfig.sentryDsn)

# Send a message to Sentry with a tag
Sentry.getContext().addTag("status", status)
Sentry.capture(message)
Sentry.getContext().clear()
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p><strong>In addition, you have to</strong> <strong>add</strong> a <code>.sentryclirc</code> file. This file should contain:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash">[defaults]
url=GLITCHTIP_APP_DOMAIN_NAME
org=clever-cloud
project=myakka
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Configure Glitchtip environment variables</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Use the <code>post_build.sh</code> script as <code>CC_POST_BUILD_HOOK</code>. This will run the  mandatory <code>sbt flywayMigrate</code> as well as create a new release on Sentry (based on the commit ID). </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Set CC_POST_BUILD_HOOK
clever env -a myakka set CC_POST_BUILD_HOOK "./post_build.sh"
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>You also need to set Glitchtip token and Glitchtip dsn as environnement variables:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Set Glitchip required env variables
clever env -a myakka set SENTRY_AUTH_TOKEN &lt; custom_glitchtip_token &gt;  
clever env -a myakka set SENTRY_DSN &lt; custom_glitchtip_dsn &gt;  
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy the application</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can now deploy myakka project:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Deploy myakka
clever deploy
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Try it </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As soon as this done, you should see your first issue on Glitchip! That's all, you can now add all the application you want to Glitchtip and enjoy this tool to centralise your application logs and errors.  If you're used to this product or just try it feel free to share with us any feedback <a href="https://twitter.com/clever_cloud">on Twitter</a>.</p>
<!-- /wp:paragraph -->]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2022/06/glitchtip.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="glitchtip" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2022/06/glitchtip.png 1400w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2022/06/glitchtip-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph -->
<p>At Clever Cloud, we like to have some context about our application status and logs. That's why we have a lot of tools deployed to gain some observability. A lot of them are freely available for our customers (a log view, a metrics view or Grafana). Still, there are some tools that we use internally that could be helpful to many. We discovered recently <a href="https://glitchtip.com/" target="_blank" rel="noreferrer noopener">glichtip</a>, which is an open source error tracking. Glichtip is a great alternative to Sentry and less complex to deploy. We will add that Glichtip is compatible with the <a href="https://docs.sentry.io/platforms/">Sentry's open source SDK</a>.  </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Context</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We used Sentry to analyse the errors coming from our own application logs. We were still using the <code>9.1</code> version until we had too many trouble to keep it running. We then had to upgrade or find a new solution. All Sentry version post <code>9.1</code> require many more components to deploy (as Kafka, Snuba or Clickhouse). This is still possible to deploy it with a <a href="https://develop.sentry.dev/self-hosted/">self hosted script</a>. We wanted every component to be standalone outside of the main Sentry application, it meant that we had to provide authentication to all components. It was not a big issue, but it took us more time that what we first expected. And at the same time, we discovered a new project: Glitchtip. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Glitchtip</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>All started by a French <a href="https://twitter.com/aeris22/status/1516411508225417228?t=EdjijoImwBdKwOjI63m5-A&amp;s=19">tweet</a>, about the discovery of a new tool: <a href="https://glitchtip.com/">Glitchtip</a>. This tweet said that Glitchtip is compatible to Sentry, free and easy to self host it, so it was evident that we were going to give it a try.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>What does Glitchtip provide? Inside your application, with the Sentry SDK, you will transfer some of your error logs. Then the tool help you to track those errors, to better understand when a new version tool creates new errors,  organize or search them... In a quick word, it's a very useful tool to debug your deployed software. </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Clever Cloud deploy </h2>
<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Setup</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>First, we will download Glitchtip <code>Docker</code> project and customize it a bit to match how docker applications are run in Clever Cloud.</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Get latest Glitchtip release
git clone https://gitlab.com/glitchtip/glitchtip.git

# Go to the folder
cd glitchtip
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Then open your favorite code IDE and open the <code>Dockerfile</code>: </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Remove
FROM glitchtip/glitchtip:latest

# And add instead:
FROM glitchtip/glitchtip:v1.12.2

COPY docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Here we will set-up the last Glitchtip release. When we were writing this blog it was the <code>v1.12.2</code>. You can find them <a href="https://hub.docker.com/r/glitchtip/glitchtip/tags">here</a>. We set up a new script to use <code>docker-entrypoint.sh</code> which will enable us to start or the Glitchtip web application or the Glitchtip worker. The <code>docker-entrypoint.sh</code> should contain the following script:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># docker-entrypoint.sh script:
#!/bin/bash

if [ "${START_TARGET}" = "worker" ]; then
  mkdir /tmp/sandboxed
	cd /tmp/sandboxed &amp;&amp; nohup python -m http.server 8080 &amp;
	/code/bin/run-celery-with-beat.sh
else
  /code/bin/start.sh
fi

# Don't forget to make it executable:
chmod u+x docker-entrypoint.sh
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Glitchtip comes with a <code>Dockerfile</code>, which means we will use a <a href="https://www.clever.cloud/developers/deploy/application/java/java-jar/">a docker runtime</a>. It also requires a <a href="https://www.postgresql.org/">PostgreSQL Database</a> and <a href="https://redis.io/">a Redis cache</a>, which means we will deploy a <a href="https://www.clever.cloud/developers/doc/addons/postgresql/">PostgreSQL</a><a href="https://www.clever.cloud/developers/deploy/addon/postgresql/postgresql/"> addon</a> and a <a href="https://www.clever.cloud/developers/doc/addons/redis/">Redis addon.</a> Adding a <code>-o</code> option in all <code>create</code> command line can be used to specify which organisation to use.</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Create the docker applications:
clever create --type docker glitchtip-web
clever create --type docker glitchtip-worker

# Create the PG addon
clever addon create postgresql-addon --plan s_sml --addon-version 14 glitchtip-postgres

# Link the addon
clever service link-addon glitchtip-postgres -a glitchtip-web
clever service link-addon glitchtip-postgres -a glitchtip-worker

# Create the Redis addon
clever addon create redis-addon --plan s_mono glitchtip-redis

# Link the addon
clever service link-addon glitchtip-redis -a glitchtip-web
clever service link-addon glitchtip-redis -a glitchtip-worker
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Config</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For now we will configure Glitchtip through environment variables. As we use several applications, let's deploy an addon configuration provider. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Create a config addon:
clever addon create config-provider --plan std glitchtip-config

# Link the addon
clever service link-addon glitchtip-config -a glitchtip-web
clever service link-addon glitchtip-config -a glitchtip-worker

</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Now that we have deployed a config addon provider let's update its configuration. To do it go to the Clever Cloud console and then select the <code>glitchtip-config</code>. In the variable panel, select the <code>expert</code> mode and add the following required variable, (fill their value based on the provided commentary):</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># In the config addon provider add:
CC_DOCKER_EXPOSED_HTTP_PORT="8080"
# Copy paste here the POSTGRESQL_ADDON_URI environment variable of the glitchtip-postgres addon 
DATABASE_URL="postgresql://user:password@host:port/database"
# Provide a valid email server
EMAIL_URL="smtp://email:password@smtp_url:port"
# Copy paste here the application domain name of the glitchtip-web application instead (should look like: https://app-da7a7a7a-da7a-4242-7a7a-da7a42427a7a.cleverapps.io)
GLITCHTIP_DOMAIN="MY_APP_DOMAIN_NAME"
# Copy paste here the REDIS_ADDON's environment variable of the glitchtip-redis addon 
REDIS_HOST= &lt; REDIS_HOST &gt;
REDIS_PASSWORD= &lt; REDIS_PASSWORD &gt; 
REDIS_PORT= &lt; REDIS_PORT &gt;
# Generate your own custom secret key for Glitchtip
SECRET_KEY= &lt; choose a secret key &gt;
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Note that you can find more information about how to configure Glitchtip in its <a href="https://glitchtip.com/documentation/install#configuration">documentation</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Each docker application requires some custom configuration too:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash">#glitchtip-web custom env
clever env set CC_RUN_SUCCEEDED_HOOK "./manage.py migrate" -a glitchtip-web
clever env set START_TARGET "web" -a glitchtip-web
#glitchtip-worker custom env
clever env set START_TARGET "worker" -a glitchtip-worker
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy and run</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Now that everything is set, it's time to deploy and run your Glitchtip application. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Remove initial git
rm -r .git 

# Init a git repository
git init

# Add your files
git add .

# Commit the changes
git commit -m "clever init and deploy"

# Deploy the application
clever deploy -a glitchtip-web
clever deploy -a glitchtip-worker

# Open Glitchtip in your browser
clever open -a glitchtip-web
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Your glitchtip is now almost ready to use. One last action is required: you need to create a super user to administrate Glitchtip. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Connect in SSH to your Clever application:
clever ssh -a glitchtip-web

# Run 
./manage.py createsuperuser
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>Great job! You should now have an access to glitchtip admin page (available on your application /admin path). You can then create users or connect to your favorite social application to authenticate your users. You will find more information on the <a href="https://glitchtip.com/documentation/install#django-admin">documentation</a>. You can set your <a href="https://www.clever.cloud/blog/fonctionnalites/2022/05/11/how-to-deploy-keycloak-on-clever-cloud/">own keycloak on Clever Cloud</a> and use it to connect to Glitchtip! </p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading">Connect Glitchtip to an application</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We will reuse the akka application example we used for our <a href="https://www.clever.cloud/blog/fonctionnalites">scala exemple blogpost</a>. And we will then see how we can forward our own error logs to Glitchtip.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Create a Glitchtip project</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The first step will be to login with new root user (or any Glitchtip user you created or linked with a social application). Glitchtip will ask you to create your organisation. In our case let's set <code>clever-cloud</code>. As we want to monitore our application error's logs, we will need to create a new project directly in Glitchtip UI. Let's call it "myakka" and create it's associated "Scala-dev" team. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Once this project is create you will be able to get a <code>DSN</code>. We will load it later as environment variable for the akka application. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Create a Glitchtip Token </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Go to <code>Profile/auth token</code> and craft a new glitchtip token with at least the following project rights: read, write and releases. Save it for later.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Setup the AKKA example application on Clever Cloud</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The first step will be to deploy AKKA example application on Clever Cloud as mentionned in the <a href="https://www.clever.cloud/blog/fonctionnalites">scala exemple blogpost</a>. <a href="https://github.com/CleverCloud/scala-akka-http-postgres-example" target="_blank" rel="noreferrer noopener">Clone</a> the project and instead of the main branch, use the <code>blogpost-sentry</code> one. </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Clone Clever Cloud akka example project:
git clone https://github.com/CleverCloud/scala-akka-http-postgres-example.git

# Checkout blogpost-sentry
git checkout blogpost-sentry
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>In this branch, we update a bit the application to connect it to Sentry. Then we send only the starting server HTTP logs with a custom status tag (success or failure). This is code we use in the <code>blogpost-sentry</code> branch:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Register Sentry
Sentry.init(sentryConfig.sentryDsn)

# Send a message to Sentry with a tag
Sentry.getContext().addTag("status", status)
Sentry.capture(message)
Sentry.getContext().clear()
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p><strong>In addition, you have to</strong> <strong>add</strong> a <code>.sentryclirc</code> file. This file should contain:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash">[defaults]
url=GLITCHTIP_APP_DOMAIN_NAME
org=clever-cloud
project=myakka
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Configure Glitchtip environment variables</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Use the <code>post_build.sh</code> script as <code>CC_POST_BUILD_HOOK</code>. This will run the  mandatory <code>sbt flywayMigrate</code> as well as create a new release on Sentry (based on the commit ID). </p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Set CC_POST_BUILD_HOOK
clever env -a myakka set CC_POST_BUILD_HOOK "./post_build.sh"
</code></pre>
<!-- /wp:html -->

<!-- wp:paragraph -->
<p>You also need to set Glitchtip token and Glitchtip dsn as environnement variables:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Set Glitchip required env variables
clever env -a myakka set SENTRY_AUTH_TOKEN &lt; custom_glitchtip_token &gt;  
clever env -a myakka set SENTRY_DSN &lt; custom_glitchtip_dsn &gt;  
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Deploy the application</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You can now deploy myakka project:</p>
<!-- /wp:paragraph -->

<!-- wp:html -->
<pre class="wp-block-code"><code class="lang-bash"># Deploy myakka
clever deploy
</code></pre>
<!-- /wp:html -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Try it </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As soon as this done, you should see your first issue on Glitchip! That's all, you can now add all the application you want to Glitchtip and enjoy this tool to centralise your application logs and errors.  If you're used to this product or just try it feel free to share with us any feedback <a href="https://twitter.com/clever_cloud">on Twitter</a>.</p>
<!-- /wp:paragraph -->]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Grafana to plot applications metrics</title>
		<link>https://www.clever.cloud/blog/features/2021/10/28/a-grafana-to-plot-applications-metrics/</link>
		
		<dc:creator><![CDATA[Aurélien Hebert]]></dc:creator>
		<pubDate>Thu, 28 Oct 2021 14:01:46 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[metrics]]></category>
		<category><![CDATA[observability]]></category>
		<guid isPermaLink="false">https://www.clever-cloud.com/?p=3831</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/10/grafana.webp" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="grafana" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/10/grafana.webp 1400w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-300x116.webp 300w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-1024x395.webp 1024w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-768x296.webp 768w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-1368x528.webp 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph {"dropCap":true} -->
<p class="has-drop-cap">At Clever Cloud, we think it’s important to offer <strong>access</strong> to <strong>our metrics</strong> for our users. That’s why you can already query all our <a href="https://www.clever.cloud/developers/administrate/metrics/overview/">metrics</a>, and can choose between WarpScript or <a href="https://www.clever.cloud/blog/engineering/2021/10/12/enabling-promql-queries-with-erlenmeyer/">PromQL</a>. Besides, we wanted to provide <strong>more than only a metrics access</strong> to our users! We wanted to give a tool that will make you able to <strong>explore</strong> and <strong>visualize</strong> the state of your Clever Cloud applications. Internally, we’re using <a href="https://grafana.com/">Grafana</a> a lot to build monitoring dashboards, what if we can re-use this tool and build <strong>dedicated</strong> <strong>dashboards</strong>? That’s how we got the idea to release a <strong>Grafana for all of you</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":6239,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/10/grafana.svg" alt="grafana" class="wp-image-6239"/><figcaption class="wp-element-caption">Grafana</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In this blog post, we will talk about the <strong>Grafana tool</strong>. Then we will see how we <strong>deployed</strong> it. After that we will detail all actions to do to activate our <strong>Grafana Beta</strong> on your organisation. We will conclude with our <strong>dashboard’s contents</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="about-grafana">About Grafana</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://grafana.com/">Grafana</a> is an <strong>open-source</strong> tool which enables among others applications metrics, alerting or log visualization. Thus Grafana’s aim is to ease to create <a href="https://grafana.com/blog/2019/05/16/worth-a-look-public-grafana-dashboards/">efficient dashboards</a>. Grafana also comes with multiple kinds of <strong>tiles</strong> or <strong>themes</strong> and provide <strong>many data sources</strong>. In our case, we will use only <a href="https://github.com/ovh/ovh-warp10-datasource">Warp10</a> and <a href="https://grafana.com/docs/grafana/latest/datasources/prometheus/">Prometheus</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="grafana-at-clever-cloud">Grafana at Clever Cloud</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For the one who wants to utilize Grafana, it's easy to deploy it today on Clever Cloud. For the French reader you can follow this <a href="https://blog.kbdev.io/dev/2021/08/24/grafana-clevercloud.html">blog post</a>. And also we released some scripts to automate it on <a href="https://github.com/CleverCloud/grafana-example">Github</a>. When we wanted to deploy a Grafana for our customers, we decided to re-use the same scripts. This is why our deployed instance runs as a Clever Cloud runtime application. We only activate an option as <code>force https</code> and add some <code>scalability</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="our-grafana-architecture">Our Grafana Architecture</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As Clever Cloud, Grafana furnishes organisation too. Then it’s easy to <strong>link both</strong> and make it available to our users. Next, we created an API endpoint to connect our Grafana to our console. All <strong>data sources</strong> exposed (Warp10 and Prometheus) are <strong>handled on our side. This means that no users can change them</strong>. However we <strong>cyclically</strong> <strong>refresh</strong> all <strong>tokens</strong>. In the same way, we regularly update all custom dashboards we provide. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Everyone<strong> </strong>features<strong> editor rights</strong> in their organisations. This means that you can customise all dashboards as you want. We will see, later in this post, how to not generates conflicts with our templates.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="activate-the-grafana-beta-organisation">Activate the Grafana Beta Organisation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To activate our beta, you need to go to your Clever Cloud organisation view in the Clever Cloud console. Then you will have access to a page called <code>Metrics in Grafana</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="available-dashboards">Available Dashboards</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We built three unique dashboards for you! First we will start by a tour of an organisation metrics. Then we will get more into the details of a runtime view. And finally we will see what we bring for the add-ons. <strong>Most graph of all Grafana dashboards contains a small information tile. There, you can retrieve a bit of help and description</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="clever-cloud-organisation">Clever Cloud Organisation</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The organisation view is the <strong>home</strong> <strong>dashboard</strong> in Grafana. It provides some <strong>insights</strong> about your organisation. Here, we expose some key information about the applications, the flavours and the image types. Besides, as a home, you will access some links here. You can go to all Clever Cloud template dashboards as well as the ones you set as <strong>favourite</strong> in Grafana. You can also find out direct link to reach an application.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A tile I want to explain a bit more is the deployment <strong>state graph</strong>. What is done on this tile? Every <strong>new</strong> <strong>deployment</strong> generates a new state. We plot only each one occurring during the Grafana time range. And finally this dashboard includes a metrics counting the average <strong>requests rate</strong> per minutes, computed from the access logs.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":4862,"width":667,"height":375,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large is-resized"><img src="https://cdn.clever-cloud.com/uploads/2021/12/home.png" alt="Grafana Metrics Home" class="wp-image-4862" style="width:667px;height:375px" width="667" height="375"/><figcaption class="wp-element-caption">Grafana home dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="application-runtime-dashboard">Application Runtime Dashboard</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I will now introduce the runtime dashboard. In this dashboard we retrieve several parts. First we start with a quick overview of your <strong>application</strong> <strong>state</strong>. Then we will have access to more details sections. Those sections will be about classical system metrics as the CPU, the load, the memory, the disks and the networks. Moreover in each segment, you will find many graphs as the <strong>usage</strong> or when the <strong>resource</strong> <strong>is</strong> <strong>saturated</strong>. To compute this last metrics, we apply a linear regression.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":6235,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://cdn.clever-cloud.com/uploads/2021/10/runtime-1.png" alt="runtime_board_grafana" class="wp-image-6235"/><figcaption class="wp-element-caption">Grafana runtime dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="add-on-dashboard">Add-on Dashboard</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The last dashboard contains the add-on metrics view. A first panel contains <strong>system</strong>-<strong>related</strong> metrics as the CPU, the memory, the disks or the network. A second one show the <strong>database</strong> metrics. This is where you will retrieve data as connections count, transactions, errors, deadlocks or tuple operations. However we collect custom data on a limited pool of add-on. This means there are only four of them: MySQL, PostgreSQL, Redis and MongoDB.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":4863,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://cdn.clever-cloud.com/uploads/2021/12/addon.png" alt="" class="wp-image-4863"/><figcaption class="wp-element-caption">Grafana add-on dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="customize-your-grafana-organisation">Customize Your Grafana Organisation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You have full right to <strong>edit</strong> all dashboard saved in your Grafana organisation. This means you can edit our templates. However we will update them every once in a while. As a result all your dashboards will always be up to date. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We store all our templates on the <code>Clever Cloud</code> folder. However, you can create custom dashboards <strong>anywhere else</strong>, we will never update them! </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The Grafana <code>manage view</code> lists all folders and files. Besides, this view is helpful to <strong>organise</strong> and to <strong>create</strong> new folders!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3832,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/10/Manage_Grafana.png" alt="Grafana manage view" class="wp-image-3832"/><figcaption class="wp-element-caption">Grafana manage view</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>At any time you can <strong>reset</strong> our templates. For example in case you made unwanted changes. In that case, you can reach the Grafana page of your Clever Cloud organisation. Then click on <code>reset all dashboards</code>. Finally, all <code>Clever Cloud</code> ones will be back to their initial states.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="share-your-experience">Share Your Experience</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Thank you for <strong>reading</strong> this post, we will be more than happy to get some feedback! How do you use our available data? Is there something missing for your use case on what we have provided? I hope you will enjoy this new data ride!</p>
<!-- /wp:paragraph -->]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/10/grafana.webp" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="grafana" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/10/grafana.webp 1400w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-300x116.webp 300w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-1024x395.webp 1024w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-768x296.webp 768w, https://cdn.clever-cloud.com/uploads/2021/10/grafana-1368x528.webp 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph {"dropCap":true} -->
<p class="has-drop-cap">At Clever Cloud, we think it’s important to offer <strong>access</strong> to <strong>our metrics</strong> for our users. That’s why you can already query all our <a href="https://www.clever.cloud/developers/administrate/metrics/overview/">metrics</a>, and can choose between WarpScript or <a href="https://www.clever.cloud/blog/engineering/2021/10/12/enabling-promql-queries-with-erlenmeyer/">PromQL</a>. Besides, we wanted to provide <strong>more than only a metrics access</strong> to our users! We wanted to give a tool that will make you able to <strong>explore</strong> and <strong>visualize</strong> the state of your Clever Cloud applications. Internally, we’re using <a href="https://grafana.com/">Grafana</a> a lot to build monitoring dashboards, what if we can re-use this tool and build <strong>dedicated</strong> <strong>dashboards</strong>? That’s how we got the idea to release a <strong>Grafana for all of you</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":6239,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/10/grafana.svg" alt="grafana" class="wp-image-6239"/><figcaption class="wp-element-caption">Grafana</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>In this blog post, we will talk about the <strong>Grafana tool</strong>. Then we will see how we <strong>deployed</strong> it. After that we will detail all actions to do to activate our <strong>Grafana Beta</strong> on your organisation. We will conclude with our <strong>dashboard’s contents</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="about-grafana">About Grafana</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p><a href="https://grafana.com/">Grafana</a> is an <strong>open-source</strong> tool which enables among others applications metrics, alerting or log visualization. Thus Grafana’s aim is to ease to create <a href="https://grafana.com/blog/2019/05/16/worth-a-look-public-grafana-dashboards/">efficient dashboards</a>. Grafana also comes with multiple kinds of <strong>tiles</strong> or <strong>themes</strong> and provide <strong>many data sources</strong>. In our case, we will use only <a href="https://github.com/ovh/ovh-warp10-datasource">Warp10</a> and <a href="https://grafana.com/docs/grafana/latest/datasources/prometheus/">Prometheus</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="grafana-at-clever-cloud">Grafana at Clever Cloud</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>For the one who wants to utilize Grafana, it's easy to deploy it today on Clever Cloud. For the French reader you can follow this <a href="https://blog.kbdev.io/dev/2021/08/24/grafana-clevercloud.html">blog post</a>. And also we released some scripts to automate it on <a href="https://github.com/CleverCloud/grafana-example">Github</a>. When we wanted to deploy a Grafana for our customers, we decided to re-use the same scripts. This is why our deployed instance runs as a Clever Cloud runtime application. We only activate an option as <code>force https</code> and add some <code>scalability</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="our-grafana-architecture">Our Grafana Architecture</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>As Clever Cloud, Grafana furnishes organisation too. Then it’s easy to <strong>link both</strong> and make it available to our users. Next, we created an API endpoint to connect our Grafana to our console. All <strong>data sources</strong> exposed (Warp10 and Prometheus) are <strong>handled on our side. This means that no users can change them</strong>. However we <strong>cyclically</strong> <strong>refresh</strong> all <strong>tokens</strong>. In the same way, we regularly update all custom dashboards we provide. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>Everyone<strong> </strong>features<strong> editor rights</strong> in their organisations. This means that you can customise all dashboards as you want. We will see, later in this post, how to not generates conflicts with our templates.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="activate-the-grafana-beta-organisation">Activate the Grafana Beta Organisation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>To activate our beta, you need to go to your Clever Cloud organisation view in the Clever Cloud console. Then you will have access to a page called <code>Metrics in Grafana</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading" id="available-dashboards">Available Dashboards</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We built three unique dashboards for you! First we will start by a tour of an organisation metrics. Then we will get more into the details of a runtime view. And finally we will see what we bring for the add-ons. <strong>Most graph of all Grafana dashboards contains a small information tile. There, you can retrieve a bit of help and description</strong>.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="clever-cloud-organisation">Clever Cloud Organisation</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The organisation view is the <strong>home</strong> <strong>dashboard</strong> in Grafana. It provides some <strong>insights</strong> about your organisation. Here, we expose some key information about the applications, the flavours and the image types. Besides, as a home, you will access some links here. You can go to all Clever Cloud template dashboards as well as the ones you set as <strong>favourite</strong> in Grafana. You can also find out direct link to reach an application.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>A tile I want to explain a bit more is the deployment <strong>state graph</strong>. What is done on this tile? Every <strong>new</strong> <strong>deployment</strong> generates a new state. We plot only each one occurring during the Grafana time range. And finally this dashboard includes a metrics counting the average <strong>requests rate</strong> per minutes, computed from the access logs.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":4862,"width":667,"height":375,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large is-resized"><img src="https://cdn.clever-cloud.com/uploads/2021/12/home.png" alt="Grafana Metrics Home" class="wp-image-4862" style="width:667px;height:375px" width="667" height="375"/><figcaption class="wp-element-caption">Grafana home dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="application-runtime-dashboard">Application Runtime Dashboard</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>I will now introduce the runtime dashboard. In this dashboard we retrieve several parts. First we start with a quick overview of your <strong>application</strong> <strong>state</strong>. Then we will have access to more details sections. Those sections will be about classical system metrics as the CPU, the load, the memory, the disks and the networks. Moreover in each segment, you will find many graphs as the <strong>usage</strong> or when the <strong>resource</strong> <strong>is</strong> <strong>saturated</strong>. To compute this last metrics, we apply a linear regression.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":6235,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://cdn.clever-cloud.com/uploads/2021/10/runtime-1.png" alt="runtime_board_grafana" class="wp-image-6235"/><figcaption class="wp-element-caption">Grafana runtime dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading" id="add-on-dashboard">Add-on Dashboard</h4>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>The last dashboard contains the add-on metrics view. A first panel contains <strong>system</strong>-<strong>related</strong> metrics as the CPU, the memory, the disks or the network. A second one show the <strong>database</strong> metrics. This is where you will retrieve data as connections count, transactions, errors, deadlocks or tuple operations. However we collect custom data on a limited pool of add-on. This means there are only four of them: MySQL, PostgreSQL, Redis and MongoDB.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"align":"center","id":4863,"sizeSlug":"large","linkDestination":"none"} -->
<figure class="wp-block-image aligncenter size-large"><img src="https://cdn.clever-cloud.com/uploads/2021/12/addon.png" alt="" class="wp-image-4863"/><figcaption class="wp-element-caption">Grafana add-on dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="customize-your-grafana-organisation">Customize Your Grafana Organisation</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You have full right to <strong>edit</strong> all dashboard saved in your Grafana organisation. This means you can edit our templates. However we will update them every once in a while. As a result all your dashboards will always be up to date. </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>We store all our templates on the <code>Clever Cloud</code> folder. However, you can create custom dashboards <strong>anywhere else</strong>, we will never update them! </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>The Grafana <code>manage view</code> lists all folders and files. Besides, this view is helpful to <strong>organise</strong> and to <strong>create</strong> new folders!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":3832,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/10/Manage_Grafana.png" alt="Grafana manage view" class="wp-image-3832"/><figcaption class="wp-element-caption">Grafana manage view</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>At any time you can <strong>reset</strong> our templates. For example in case you made unwanted changes. In that case, you can reach the Grafana page of your Clever Cloud organisation. Then click on <code>reset all dashboards</code>. Finally, all <code>Clever Cloud</code> ones will be back to their initial states.</p>
<!-- /wp:paragraph -->

<!-- wp:heading -->
<h2 class="wp-block-heading" id="share-your-experience">Share Your Experience</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>Thank you for <strong>reading</strong> this post, we will be more than happy to get some feedback! How do you use our available data? Is there something missing for your use case on what we have provided? I hope you will enjoy this new data ride!</p>
<!-- /wp:paragraph -->]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Enabling PromQL queries with Erlenmeyer</title>
		<link>https://www.clever.cloud/blog/engineering/2021/10/12/enabling-promql-queries-with-erlenmeyer/</link>
		
		<dc:creator><![CDATA[Aurélien Hebert]]></dc:creator>
		<pubDate>Tue, 12 Oct 2021 07:28:09 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[metrics]]></category>
		<category><![CDATA[observability]]></category>
		<category><![CDATA[prometheus]]></category>
		<category><![CDATA[warp10]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/?p=3031</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="erlenmeyer promql 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><div>You are using Clever Cloud to deploy <strong>applications runtimes</strong> or <strong>add-ons</strong>. But do you know that all Clever Cloud services are producing <strong>metrics?</strong> And that <a href="https://www.clever.cloud/developers/administrate/metrics/overview/">you already have&nbsp;<strong>access</strong> to all of them</a>? Indeed, we register an <strong>agent</strong> on our side, whose job is to collect all local data.<span id="more-3031"></span>Once it's done, they are stored in a Time Series database called <strong><a href="https://www.warp10.io/">Warp10</a></strong>.</div>
<div><img class="alignleft wp-image-3049 size-full" src="https://cdn.clever-cloud.com/uploads/2021/08/erlenmeyer_logo.png" alt="Erlenmeyer logo" width="643" height="205">
<div>
<div>To simplify the adoption of Warp10, the OVHcloud Metrics team built the <strong><a href="https://github.com/ovh/erlenmeyer">Erlenmeyer</a></strong> tool. In the first place, this tool enables the use of <strong>several open source protocols</strong> as PromQL, OpenTSDB, InfluxQL or Graphite to query Warp10 stored metrics.</div>
<div>Secondly, Erlenmeyer works as a proxy in front of a Warp10 cluster. Then we deployed a couple of&nbsp;Erlenmeyer instances in front of our Warp10 infrastructure, naturally providing new ways to query your application metrics.</div>
</div>
<blockquote>In this post, we will review what Erlenmeyer brings and how to handle Clever Cloud services metrics with <strong>PromQL</strong>.</blockquote>
</div>
<div>
<h2>Erlenmeyer protocols</h2>
<div>
<div>Erlenmeyer almost entirely enables <a href="https://www.ovh.com/blog/erlenmeyer-and-promql-compatibility/">PromQL queries</a>, OpenTSDB, InfluxQL and some of the Graphite functions. Moreover, you can retrieve the documentation about each protocol implementation and usage on Erlenmeyer's GitHub:</div>
<ul>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/promql.md">PromQL</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/openTSDB.md">OpenTSDB</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/influxql.md">InfluxQL</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/graphite.md">Graphite</a></li>
</ul>
On Clever Cloud, we deployed an <code>Erlenmeyer</code> in front of our Warp10 backend. This means <strong>all</strong> these <strong>open source protocols</strong> can be used to query our application Metrics. The <strong>host</strong> is <code>https://PROTO-c1-warp10-clevercloud-customers.services.clever-cloud.com/PROTO</code> with <code>PROTO</code> being:

</div>
<div>
<div>
<ul>
 	<li>for PromQL: <code>prometheus</code>,</li>
 	<li>for OpenTSDB: <code>opentsdb</code>,</li>
 	<li>for InfluxQL: <code>influxql</code>,</li>
 	<li>for Graphite: <code>graphite</code>.</li>
</ul>
<div>To authenticate your request, you need to use the Warp10 READ TOKEN as the password of the basic authentication. You can find it in the metrics panel of any Clever Cloud application:</div>
<div></div>
<div></div>
<div>
<div><img class="aligncenter wp-image-3059 size-full" src="https://cdn.clever-cloud.com/uploads/2021/09/Token.png" alt="Metrics token in the console" width="858" height="359"></div>
<div></div>
</div>
</div>
</div>
<div></div>
<div>
<div>
<div>
<div>
<h2>Retrieve the memory data with PromQL</h2>
<div>As a first step, let's store the Warp10 <code>READ TOKEN</code> and an <code>APP_ID</code> as an <strong>environment variable</strong>:</div>
</div>
<div></div>
</div>
<div>
<div>
<pre><code class="language-shell">export TOKEN=MY_AWESOME_TOKEN # Replace the value by your Clever Cloud Warp10 token
export APP_ID=app_test # Replace the value by one of your own Clever Cloud application
</code></pre>
</div>
</div>
</div>
<div>
<h3>Get raw data</h3>
</div>
<div>
<div>
<div>
<div>To retrieve the <code>mem.used_percent</code> in <strong>PromQL</strong>, we need to send an <code>HTTP GET</code> request to Erlenmeyer, with the TOKEN as basic AUTH. In that case, the PromQL <code>GET</code> request requires four parameters: query, start, end and step. Similarly, to learn more about the PromQL language, you can read the <a href="https://prometheus.io/docs/prometheus/latest/querying/basics/">Prometheus documentation</a>. In our case we will create a simple query to get the raw data:</div>
</div>
</div>
</div>
<div>
<div>
<div>
<pre><code class="language-shell">api/v1/query_range?
query=mem.used_percent{app_id="$APP_ID"}&amp;
start=1623289800&amp;
end=1623311400&amp;
step=120s</code></pre>
</div>
<div>
<div>The <code>query</code> parameter is used for the PromQL queries: <code>start</code> and <code>end</code> are milliseconds timestamps corresponding to the time limit to get data. And the <code>step</code> one is the <strong>sampling</strong> parameter.</div>
<div>As data are collected around every minute, let's set at least twice the duration:&nbsp;<code>120s</code>.</div>
<div></div>
<div>Now, to get the result, execute the following <code>cURL</code> <strong>url encoded</strong>:</div>
<div></div>
</div>
<pre><code class="language-shell">curl --request GET --url "https://u:${TOKEN}@prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/api/v1/query_range?query=mem.used_percent%7Bapp_id%3D%22${APP_ID}%22%7D&amp;start=1623289800&amp;end=1623311400&amp;step=120s" --header 'Content-Type: application/json'
</code></pre>
<div>
<div>
<h3>Group by example</h3>
A group by query can be useful in the Clever Cloud case to merge some series (multiple deployments or instances). Thus we will <strong>group</strong> data based on the <code>app_id</code> labels in the following example.
<div>We will re-use the stored variable <code>READ_TOKEN</code>&nbsp; and <code>APP_ID</code>. To compute a group by in our case we apply the <code>max</code> PromQL <strong>function</strong> grouped by the series <code>app_id</code> label:</div>
<div></div>
</div>
<pre><code class="language-shell">api/v1/query_range?
query=max(mem.used_percent{app_id="$APP_ID"}) by (app_id)&amp;
start=1623289800&amp;
end=1623311400&amp;
step=120s
</code></pre>
<div>
<div>Finally to get the result, execute the following <code>cURL</code> <strong>url encoded</strong>:</div>
<div></div>
<pre><code class="language-shell">curl --request GET --url "https://u:${TOKEN}@prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/api/v1/query_range?query=max(mem.used_percent%7Bapp_id%3D%22${APP_ID}%22%7D)%20by%20(app_id)&amp;start=1623289800&amp;end=1623311400&amp;step=120s" --header 'Content-Type: application/json'
</code></pre>
</div>
</div>
<div>
<div>
<h2>Grafana PromQL data source</h2>
You may use <a href="https://grafana.com/">Grafana</a> to create you own dashboards, which is an open source interactive visualisation web application (to deploy a Grafana as a Clever Cloud application, we provide a <a href="https://github.com/CleverCloud/grafana-example">github example</a> and you can also follow this <a href="https://blog.kbdev.io/dev/2021/08/24/grafana-clevercloud.html">French blog post</a>). Of course you can configure a <strong>PromQL</strong> <strong>data source</strong> to get Clever Cloud applications metrics:

</div>
<ul>
 	<li>create a <strong>Prometheus</strong> source,</li>
 	<li>then set Prometheus source <strong>host</strong> to <code>https://prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus</code>,</li>
 	<li>in addition activate the<strong> basic authentication</strong> with a <strong>user</strong> set to <code>metrics</code> and a <strong>password</strong> containing your <code>read Warp10 token</code>,</li>
 	<li>to conclude, click on <code>Save and Test</code>, your Prometheus data source should now be working!</li>
</ul>
</div>
</div>
<div>
<div>
<div>
<div>
<div><img class="aligncenter wp-image-3076 size-full" src="https://cdn.clever-cloud.com/uploads/2021/09/PromQL_source_grafana.png" alt="PromQL Grafana data source configuration" width="773" height="781"></div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<h2>Prometheus UI with remote_read endpoint</h2>
Like with Grafana, you can use <a href="https://prometheus.io/docs/introduction/overview/">Prometheus</a> and plot Clever Cloud metrics in the <strong>Web UI</strong>. And as a matter of fact, simply fill your Prometheus <strong>configuration</strong> with a <strong>remote_read</strong> source:
<pre><code class="language-yaml">api/v1/query_range?
remote_read:
  - url: "https://prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/remote_read/"
  basic_auth:
    username: "metrics"
    password: "TOKEN"
</code></pre>
<div></div>
<div>Restart Prometheus, then simply execute a Prometheus query in the UI as below:</div>
<pre><code class="language-shell">{ __name__= "mem.used_percent", app_id="$APP_ID" }
</code></pre>
<div>Our backend is able to correctly resolve <code>.</code>&nbsp; which are invalid prometheus characters. Nonetheless the backend response will always translate those <code>.</code> values in series data (name or labels) into valid <code>_</code>.</div>
</div>
<h2>To Sum Up</h2>
As you can see with this post, you can get metrics of Clever Cloud applications and add-ons. Presently you now have <strong>one more way</strong> to query them, as Erlenmeyer allows the use of <code>PromQL</code>. However the drawback is that you will have to <strong>update regularly your token</strong>, as they expire in a few days. We are working on a solution to improve the user experience. First, we will soon provide our customers with access to a <strong>Grafana</strong> with <strong>configured data source and already pre-filled dashboards</strong>. The <strong>token</strong> will be handled on our side and you will then be able to build your own graphs with <code>PromQL</code> or <code>WarpScript</code> queries.

</div>
</div>
</div>]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="erlenmeyer promql 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/10/erlenmeyer-promql-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><div>You are using Clever Cloud to deploy <strong>applications runtimes</strong> or <strong>add-ons</strong>. But do you know that all Clever Cloud services are producing <strong>metrics?</strong> And that <a href="https://www.clever.cloud/developers/administrate/metrics/overview/">you already have&nbsp;<strong>access</strong> to all of them</a>? Indeed, we register an <strong>agent</strong> on our side, whose job is to collect all local data.<span id="more-3031"></span>Once it's done, they are stored in a Time Series database called <strong><a href="https://www.warp10.io/">Warp10</a></strong>.</div>
<div><img class="alignleft wp-image-3049 size-full" src="https://cdn.clever-cloud.com/uploads/2021/08/erlenmeyer_logo.png" alt="Erlenmeyer logo" width="643" height="205">
<div>
<div>To simplify the adoption of Warp10, the OVHcloud Metrics team built the <strong><a href="https://github.com/ovh/erlenmeyer">Erlenmeyer</a></strong> tool. In the first place, this tool enables the use of <strong>several open source protocols</strong> as PromQL, OpenTSDB, InfluxQL or Graphite to query Warp10 stored metrics.</div>
<div>Secondly, Erlenmeyer works as a proxy in front of a Warp10 cluster. Then we deployed a couple of&nbsp;Erlenmeyer instances in front of our Warp10 infrastructure, naturally providing new ways to query your application metrics.</div>
</div>
<blockquote>In this post, we will review what Erlenmeyer brings and how to handle Clever Cloud services metrics with <strong>PromQL</strong>.</blockquote>
</div>
<div>
<h2>Erlenmeyer protocols</h2>
<div>
<div>Erlenmeyer almost entirely enables <a href="https://www.ovh.com/blog/erlenmeyer-and-promql-compatibility/">PromQL queries</a>, OpenTSDB, InfluxQL and some of the Graphite functions. Moreover, you can retrieve the documentation about each protocol implementation and usage on Erlenmeyer's GitHub:</div>
<ul>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/promql.md">PromQL</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/openTSDB.md">OpenTSDB</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/influxql.md">InfluxQL</a></li>
 	<li><a href="https://github.com/ovh/erlenmeyer/blob/master/doc/graphite.md">Graphite</a></li>
</ul>
On Clever Cloud, we deployed an <code>Erlenmeyer</code> in front of our Warp10 backend. This means <strong>all</strong> these <strong>open source protocols</strong> can be used to query our application Metrics. The <strong>host</strong> is <code>https://PROTO-c1-warp10-clevercloud-customers.services.clever-cloud.com/PROTO</code> with <code>PROTO</code> being:

</div>
<div>
<div>
<ul>
 	<li>for PromQL: <code>prometheus</code>,</li>
 	<li>for OpenTSDB: <code>opentsdb</code>,</li>
 	<li>for InfluxQL: <code>influxql</code>,</li>
 	<li>for Graphite: <code>graphite</code>.</li>
</ul>
<div>To authenticate your request, you need to use the Warp10 READ TOKEN as the password of the basic authentication. You can find it in the metrics panel of any Clever Cloud application:</div>
<div></div>
<div></div>
<div>
<div><img class="aligncenter wp-image-3059 size-full" src="https://cdn.clever-cloud.com/uploads/2021/09/Token.png" alt="Metrics token in the console" width="858" height="359"></div>
<div></div>
</div>
</div>
</div>
<div></div>
<div>
<div>
<div>
<div>
<h2>Retrieve the memory data with PromQL</h2>
<div>As a first step, let's store the Warp10 <code>READ TOKEN</code> and an <code>APP_ID</code> as an <strong>environment variable</strong>:</div>
</div>
<div></div>
</div>
<div>
<div>
<pre><code class="language-shell">export TOKEN=MY_AWESOME_TOKEN # Replace the value by your Clever Cloud Warp10 token
export APP_ID=app_test # Replace the value by one of your own Clever Cloud application
</code></pre>
</div>
</div>
</div>
<div>
<h3>Get raw data</h3>
</div>
<div>
<div>
<div>
<div>To retrieve the <code>mem.used_percent</code> in <strong>PromQL</strong>, we need to send an <code>HTTP GET</code> request to Erlenmeyer, with the TOKEN as basic AUTH. In that case, the PromQL <code>GET</code> request requires four parameters: query, start, end and step. Similarly, to learn more about the PromQL language, you can read the <a href="https://prometheus.io/docs/prometheus/latest/querying/basics/">Prometheus documentation</a>. In our case we will create a simple query to get the raw data:</div>
</div>
</div>
</div>
<div>
<div>
<div>
<pre><code class="language-shell">api/v1/query_range?
query=mem.used_percent{app_id="$APP_ID"}&amp;
start=1623289800&amp;
end=1623311400&amp;
step=120s</code></pre>
</div>
<div>
<div>The <code>query</code> parameter is used for the PromQL queries: <code>start</code> and <code>end</code> are milliseconds timestamps corresponding to the time limit to get data. And the <code>step</code> one is the <strong>sampling</strong> parameter.</div>
<div>As data are collected around every minute, let's set at least twice the duration:&nbsp;<code>120s</code>.</div>
<div></div>
<div>Now, to get the result, execute the following <code>cURL</code> <strong>url encoded</strong>:</div>
<div></div>
</div>
<pre><code class="language-shell">curl --request GET --url "https://u:${TOKEN}@prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/api/v1/query_range?query=mem.used_percent%7Bapp_id%3D%22${APP_ID}%22%7D&amp;start=1623289800&amp;end=1623311400&amp;step=120s" --header 'Content-Type: application/json'
</code></pre>
<div>
<div>
<h3>Group by example</h3>
A group by query can be useful in the Clever Cloud case to merge some series (multiple deployments or instances). Thus we will <strong>group</strong> data based on the <code>app_id</code> labels in the following example.
<div>We will re-use the stored variable <code>READ_TOKEN</code>&nbsp; and <code>APP_ID</code>. To compute a group by in our case we apply the <code>max</code> PromQL <strong>function</strong> grouped by the series <code>app_id</code> label:</div>
<div></div>
</div>
<pre><code class="language-shell">api/v1/query_range?
query=max(mem.used_percent{app_id="$APP_ID"}) by (app_id)&amp;
start=1623289800&amp;
end=1623311400&amp;
step=120s
</code></pre>
<div>
<div>Finally to get the result, execute the following <code>cURL</code> <strong>url encoded</strong>:</div>
<div></div>
<pre><code class="language-shell">curl --request GET --url "https://u:${TOKEN}@prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/api/v1/query_range?query=max(mem.used_percent%7Bapp_id%3D%22${APP_ID}%22%7D)%20by%20(app_id)&amp;start=1623289800&amp;end=1623311400&amp;step=120s" --header 'Content-Type: application/json'
</code></pre>
</div>
</div>
<div>
<div>
<h2>Grafana PromQL data source</h2>
You may use <a href="https://grafana.com/">Grafana</a> to create you own dashboards, which is an open source interactive visualisation web application (to deploy a Grafana as a Clever Cloud application, we provide a <a href="https://github.com/CleverCloud/grafana-example">github example</a> and you can also follow this <a href="https://blog.kbdev.io/dev/2021/08/24/grafana-clevercloud.html">French blog post</a>). Of course you can configure a <strong>PromQL</strong> <strong>data source</strong> to get Clever Cloud applications metrics:

</div>
<ul>
 	<li>create a <strong>Prometheus</strong> source,</li>
 	<li>then set Prometheus source <strong>host</strong> to <code>https://prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus</code>,</li>
 	<li>in addition activate the<strong> basic authentication</strong> with a <strong>user</strong> set to <code>metrics</code> and a <strong>password</strong> containing your <code>read Warp10 token</code>,</li>
 	<li>to conclude, click on <code>Save and Test</code>, your Prometheus data source should now be working!</li>
</ul>
</div>
</div>
<div>
<div>
<div>
<div>
<div><img class="aligncenter wp-image-3076 size-full" src="https://cdn.clever-cloud.com/uploads/2021/09/PromQL_source_grafana.png" alt="PromQL Grafana data source configuration" width="773" height="781"></div>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<h2>Prometheus UI with remote_read endpoint</h2>
Like with Grafana, you can use <a href="https://prometheus.io/docs/introduction/overview/">Prometheus</a> and plot Clever Cloud metrics in the <strong>Web UI</strong>. And as a matter of fact, simply fill your Prometheus <strong>configuration</strong> with a <strong>remote_read</strong> source:
<pre><code class="language-yaml">api/v1/query_range?
remote_read:
  - url: "https://prometheus-c1-warp10-clevercloud-customers.services.clever-cloud.com/prometheus/remote_read/"
  basic_auth:
    username: "metrics"
    password: "TOKEN"
</code></pre>
<div></div>
<div>Restart Prometheus, then simply execute a Prometheus query in the UI as below:</div>
<pre><code class="language-shell">{ __name__= "mem.used_percent", app_id="$APP_ID" }
</code></pre>
<div>Our backend is able to correctly resolve <code>.</code>&nbsp; which are invalid prometheus characters. Nonetheless the backend response will always translate those <code>.</code> values in series data (name or labels) into valid <code>_</code>.</div>
</div>
<h2>To Sum Up</h2>
As you can see with this post, you can get metrics of Clever Cloud applications and add-ons. Presently you now have <strong>one more way</strong> to query them, as Erlenmeyer allows the use of <code>PromQL</code>. However the drawback is that you will have to <strong>update regularly your token</strong>, as they expire in a few days. We are working on a solution to improve the user experience. First, we will soon provide our customers with access to a <strong>Grafana</strong> with <strong>configured data source and already pre-filled dashboards</strong>. The <strong>token</strong> will be handled on our side and you will then be able to build your own graphs with <code>PromQL</code> or <code>WarpScript</code> queries.

</div>
</div>
</div>]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
