<?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>Aurélien Hebert, Author at Clever Cloud</title>
	<atom:link href="https://www.clever.cloud/blog/author/aurelien-hebertclever-cloud-com/feed/" rel="self" type="application/rss+xml" />
	<link></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>Aurélien Hebert, Author at Clever Cloud</title>
	<link></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>Slack alerts for Grafana</title>
		<link>https://www.clever.cloud/blog/features/2021/12/03/slack-alerts-for-grafana/</link>
		
		<dc:creator><![CDATA[Aurélien Hebert]]></dc:creator>
		<pubDate>Fri, 03 Dec 2021 13:29:40 +0000</pubDate>
				<category><![CDATA[Features]]></category>
		<guid isPermaLink="false">https://www.clever-cloud.com/?p=4167</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="slack alerts for grafana 2" decoding="async" srcset="https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2.png 1400w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-1368x528.png 1368w" sizes="(max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph -->
<p>In one of our previous posts, we announced the <a href="https://www.clever.cloud/blog/features/2021/10/28/a-grafana-to-plot-applications-metrics/">release of a dedicated Clever Cloud Grafana</a> for all <a href="https://www.clever.cloud/developers/administrate/metrics/overview/#publish-your-own-metrics">our metrics.</a> What if now, you want to receive an <strong>alert</strong> when an application is in an <strong>abnormal</strong> state? Grafana provides an alerting service that is compatible with our Warp10 backend. Let’s see how we can create Slack alerts with our or any Grafana with a <code>PromQL</code> data source. </p>
<!-- /wp:paragraph -->

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

<!-- wp:paragraph -->
<p>First, before creating any alerts, we need to configure a Grafana notifier. You can have a full list of supported Grafana notifier <a href="https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/#supported-contact-point-integrations">here</a>. However, you won't be able to configure notifiers that require an admin access, like email or SMTP. In this example, we will configure a slack channel to receive all Grafana alerts.</p>
<!-- /wp:paragraph -->

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

<!-- wp:paragraph -->
<p>To be able to receive alerts on Slack, Grafana will ask for a web hook. The process to create one with slack is <a href="https://api.slack.com/messaging/webhooks">here</a>. At the end you should obtain an active incoming web hook.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4169,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/webHookSlack.png" alt="Slack incoming webhook" class="wp-image-4169"/><figcaption class="wp-element-caption">Slack incoming webhook</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Simply copy the web hook URL and then go to the alerting main panel (bell on the left) and add a new <strong>slack</strong> <code>notification channel</code>. Configure it as done below, within the field <code>web hook URL</code>, the one from the slack application. You can set your own custom name.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4168,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Slack_notifier.png" alt="Add a slack notification channel" class="wp-image-4168"/><figcaption class="wp-element-caption">Add a Slack notification channel</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Before you validate, you can test your slack integration with the <code>Test</code> button. Without delay, in the configure slack channel, you will receive a test message.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4170,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Test_Slack_Message.png" alt="Slack notification test message" class="wp-image-4170"/><figcaption class="wp-element-caption">Slack notification test message</figcaption></figure>
<!-- /wp:image -->

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

<!-- wp:paragraph -->
<p>Now that we have enabled an alert notifier, let’s create an alert in Grafana. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Clever Cloud Available Metrics </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We will start from one of the template dashboards we release with Grafana. We deployed a preview application on a Clever Cloud organisation.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4171,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Application.png" alt="Custom application Clever Cloud dashboard" class="wp-image-4171"/><figcaption class="wp-element-caption">Custom application Clever Cloud dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>For the rest of this post, we will work on the <code>load average</code> metrics. As we can see below, it’s a simple PromQL query. However, it includes custom dashboard variables&nbsp;<code>APP_ID</code> and <code>DEPLOY_ID</code> that <strong>are not supported in Grafana alerting</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4172,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Dashboard.png" alt="Runtime load graph" class="wp-image-4172"/><figcaption class="wp-element-caption">Runtime load graph</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Before enabling the alerting,  we will keep somewhere this graph query <code>system.load1_per_cpu{app_id="APP_ID"}</code>. I will only replace the variable <code>APP_ID</code> by its value, which is available on top of the dashboard. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4173,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Runtime_ID.png" alt="Runtime ID" class="wp-image-4173"/><figcaption class="wp-element-caption">Runtime ID</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Then in order not to have our custom alerts removed at each update of the Clever Cloud dashboard templates, create a new dashboard.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4174,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Create-ne-Dashboard.png" alt="Create new dashboard" class="wp-image-4174"/><figcaption class="wp-element-caption">Create new dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Also save it in a dedicated dashboard which is not <code>Clever Cloud</code>, in our example, it’s <code>alerting</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4175,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/SaveDashboard.png" alt="Save new dashboard" class="wp-image-4175"/><figcaption class="wp-element-caption">Save new dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Finally, in this new dashboard create the same load graph with the query <code>system.load1_per_cpu{app_id="APP_ID"}</code>. As well as seen previously replace APP_ID by your own application ID. For the data source, select the <code>PromQL</code> one.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4176,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/TestAlertDashQuery.png" alt="Load application alert Graph" class="wp-image-4176"/><figcaption class="wp-element-caption">Load application alert Graph</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Set Up The Alerting</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>At this instant we have a new graph where we can set up a first alert on the load of our application. For that, go on the <code>Alert</code> panel, and configure the alert based on the parameter you want. Quickly, to get an alert working, I set up the condition to check if my metrics <strong>are below</strong> the value&nbsp;<code>0.2</code>. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4177,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/CreateFirstAlert.png" alt="Alert conditions section" class="wp-image-4177"/><figcaption class="wp-element-caption">Alert conditions section</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Then still on the <code>Alert</code> panel add the notifier you created in the first section. Here, you can customise the alert you will receive in slack: adding a message and custom tags.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4179,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/NotificationGrafana.png" alt="Alert notifier section" class="wp-image-4179"/><figcaption class="wp-element-caption">Alert notifier section</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once you have set up your alert, you can test the rule with the <code>test rule</code> button.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4178,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/TestingAlertRule.png" alt="Test rule result" class="wp-image-4178"/><figcaption class="wp-element-caption">Test rule result</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Next all you have to do is to wait for an alert to appear on Slack! Besides each alert state change will be ploted on the alert graph. After about five minutes, as I was clearly matching my alert state condition, I got two states change: one pending and one alerting. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4180,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/FirstAlertV2.png" alt="Alert states" class="wp-image-4180"/><figcaption class="wp-element-caption">Alert states</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>As soon as the alert state happens, a slack message is sent through the notifier. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4181,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertInSlack.png" alt="Slack alert test message" class="wp-image-4181"/><figcaption class="wp-element-caption">Slack alert test message</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Finally, I would like to retrieve a more ‘normal’ state. To do it, I update my alert condition and set it to<strong> above</strong> <code>0.8</code>, which is a more classical value for an alert threshold for the load metrics. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4182,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/ChangeRuleAlert.png" alt="Alert condition above 0.8" class="wp-image-4182"/><figcaption class="wp-element-caption">Alert condition above 0.8</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Instantly or almost, the state of the alert should change and comes <strong>OK</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4183,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertOk.png" alt="Alert state is OK" class="wp-image-4183"/><figcaption class="wp-element-caption">Alert state is OK</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Immediately after Grafana also send a message to slack to end the issue!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4184,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertOkSlack.png" alt="Alert OK" class="wp-image-4184"/><figcaption class="wp-element-caption">Alert ok</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading">To Sum Up</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You should now be able to configure your own alerts on Slack for Grafana! You can play with the pending time, the alert condition, when to trigger the alert, the alert message the tags and so on. In fact, all you need is a working <code>PromQL</code> query. Nonetheless remember that the Grafana alerting doesn’t support dashboard variables. Other than that, you should be able to custom the alert as you wish! </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I hope you enjoy and feel free to share with us your thought on the Alerting and the Metrics product. We will be happy to have your feedback. You can contact me directly on twitter, or send us a message through the <a href="https://www.clever.cloud/developers/administrate/metrics/overview/#comments">metrics overview comments</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph -->]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="slack alerts for grafana 2" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2.png 1400w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-300x116.png 300w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-1024x395.png 1024w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-768x296.png 768w, https://cdn.clever-cloud.com/uploads/2021/12/slack-alerts-for-grafana-2-1368x528.png 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p><!-- wp:paragraph -->
<p>In one of our previous posts, we announced the <a href="https://www.clever.cloud/blog/features/2021/10/28/a-grafana-to-plot-applications-metrics/">release of a dedicated Clever Cloud Grafana</a> for all <a href="https://www.clever.cloud/developers/administrate/metrics/overview/#publish-your-own-metrics">our metrics.</a> What if now, you want to receive an <strong>alert</strong> when an application is in an <strong>abnormal</strong> state? Grafana provides an alerting service that is compatible with our Warp10 backend. Let’s see how we can create Slack alerts with our or any Grafana with a <code>PromQL</code> data source. </p>
<!-- /wp:paragraph -->

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

<!-- wp:paragraph -->
<p>First, before creating any alerts, we need to configure a Grafana notifier. You can have a full list of supported Grafana notifier <a href="https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/#supported-contact-point-integrations">here</a>. However, you won't be able to configure notifiers that require an admin access, like email or SMTP. In this example, we will configure a slack channel to receive all Grafana alerts.</p>
<!-- /wp:paragraph -->

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

<!-- wp:paragraph -->
<p>To be able to receive alerts on Slack, Grafana will ask for a web hook. The process to create one with slack is <a href="https://api.slack.com/messaging/webhooks">here</a>. At the end you should obtain an active incoming web hook.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4169,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/webHookSlack.png" alt="Slack incoming webhook" class="wp-image-4169"/><figcaption class="wp-element-caption">Slack incoming webhook</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Simply copy the web hook URL and then go to the alerting main panel (bell on the left) and add a new <strong>slack</strong> <code>notification channel</code>. Configure it as done below, within the field <code>web hook URL</code>, the one from the slack application. You can set your own custom name.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4168,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Slack_notifier.png" alt="Add a slack notification channel" class="wp-image-4168"/><figcaption class="wp-element-caption">Add a Slack notification channel</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Before you validate, you can test your slack integration with the <code>Test</code> button. Without delay, in the configure slack channel, you will receive a test message.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4170,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Test_Slack_Message.png" alt="Slack notification test message" class="wp-image-4170"/><figcaption class="wp-element-caption">Slack notification test message</figcaption></figure>
<!-- /wp:image -->

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

<!-- wp:paragraph -->
<p>Now that we have enabled an alert notifier, let’s create an alert in Grafana. </p>
<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Clever Cloud Available Metrics </h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>We will start from one of the template dashboards we release with Grafana. We deployed a preview application on a Clever Cloud organisation.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4171,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Application.png" alt="Custom application Clever Cloud dashboard" class="wp-image-4171"/><figcaption class="wp-element-caption">Custom application Clever Cloud dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>For the rest of this post, we will work on the <code>load average</code> metrics. As we can see below, it’s a simple PromQL query. However, it includes custom dashboard variables&nbsp;<code>APP_ID</code> and <code>DEPLOY_ID</code> that <strong>are not supported in Grafana alerting</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4172,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Dashboard.png" alt="Runtime load graph" class="wp-image-4172"/><figcaption class="wp-element-caption">Runtime load graph</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Before enabling the alerting,  we will keep somewhere this graph query <code>system.load1_per_cpu{app_id="APP_ID"}</code>. I will only replace the variable <code>APP_ID</code> by its value, which is available on top of the dashboard. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4173,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Runtime_ID.png" alt="Runtime ID" class="wp-image-4173"/><figcaption class="wp-element-caption">Runtime ID</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Then in order not to have our custom alerts removed at each update of the Clever Cloud dashboard templates, create a new dashboard.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4174,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/Create-ne-Dashboard.png" alt="Create new dashboard" class="wp-image-4174"/><figcaption class="wp-element-caption">Create new dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Also save it in a dedicated dashboard which is not <code>Clever Cloud</code>, in our example, it’s <code>alerting</code>.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4175,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/SaveDashboard.png" alt="Save new dashboard" class="wp-image-4175"/><figcaption class="wp-element-caption">Save new dashboard</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Finally, in this new dashboard create the same load graph with the query <code>system.load1_per_cpu{app_id="APP_ID"}</code>. As well as seen previously replace APP_ID by your own application ID. For the data source, select the <code>PromQL</code> one.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4176,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/TestAlertDashQuery.png" alt="Load application alert Graph" class="wp-image-4176"/><figcaption class="wp-element-caption">Load application alert Graph</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading {"level":3} -->
<h3 class="wp-block-heading">Set Up The Alerting</h3>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>At this instant we have a new graph where we can set up a first alert on the load of our application. For that, go on the <code>Alert</code> panel, and configure the alert based on the parameter you want. Quickly, to get an alert working, I set up the condition to check if my metrics <strong>are below</strong> the value&nbsp;<code>0.2</code>. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4177,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/CreateFirstAlert.png" alt="Alert conditions section" class="wp-image-4177"/><figcaption class="wp-element-caption">Alert conditions section</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Then still on the <code>Alert</code> panel add the notifier you created in the first section. Here, you can customise the alert you will receive in slack: adding a message and custom tags.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4179,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/NotificationGrafana.png" alt="Alert notifier section" class="wp-image-4179"/><figcaption class="wp-element-caption">Alert notifier section</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Once you have set up your alert, you can test the rule with the <code>test rule</code> button.</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4178,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/TestingAlertRule.png" alt="Test rule result" class="wp-image-4178"/><figcaption class="wp-element-caption">Test rule result</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Next all you have to do is to wait for an alert to appear on Slack! Besides each alert state change will be ploted on the alert graph. After about five minutes, as I was clearly matching my alert state condition, I got two states change: one pending and one alerting. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4180,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/FirstAlertV2.png" alt="Alert states" class="wp-image-4180"/><figcaption class="wp-element-caption">Alert states</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>As soon as the alert state happens, a slack message is sent through the notifier. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4181,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertInSlack.png" alt="Slack alert test message" class="wp-image-4181"/><figcaption class="wp-element-caption">Slack alert test message</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Finally, I would like to retrieve a more ‘normal’ state. To do it, I update my alert condition and set it to<strong> above</strong> <code>0.8</code>, which is a more classical value for an alert threshold for the load metrics. </p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4182,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/ChangeRuleAlert.png" alt="Alert condition above 0.8" class="wp-image-4182"/><figcaption class="wp-element-caption">Alert condition above 0.8</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Instantly or almost, the state of the alert should change and comes <strong>OK</strong>!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4183,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertOk.png" alt="Alert state is OK" class="wp-image-4183"/><figcaption class="wp-element-caption">Alert state is OK</figcaption></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>Immediately after Grafana also send a message to slack to end the issue!</p>
<!-- /wp:paragraph -->

<!-- wp:image {"id":4184,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="https://cdn.clever-cloud.com/uploads/2021/11/AlertOkSlack.png" alt="Alert OK" class="wp-image-4184"/><figcaption class="wp-element-caption">Alert ok</figcaption></figure>
<!-- /wp:image -->

<!-- wp:heading -->
<h2 class="wp-block-heading">To Sum Up</h2>
<!-- /wp:heading -->

<!-- wp:paragraph -->
<p>You should now be able to configure your own alerts on Slack for Grafana! You can play with the pending time, the alert condition, when to trigger the alert, the alert message the tags and so on. In fact, all you need is a working <code>PromQL</code> query. Nonetheless remember that the Grafana alerting doesn’t support dashboard variables. Other than that, you should be able to custom the alert as you wish! </p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p>I hope you enjoy and feel free to share with us your thought on the Alerting and the Metrics product. We will be happy to have your feedback. You can contact me directly on twitter, or send us a message through the <a href="https://www.clever.cloud/developers/administrate/metrics/overview/#comments">metrics overview comments</a>.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph -->
<p></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" 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 -->]]></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>
		<item>
		<title>How to deploy Apache Superset on Clever Cloud</title>
		<link>https://www.clever.cloud/blog/engineering/2021/05/04/how-to-deploy-apache-superset-on-clever-cloud/</link>
		
		<dc:creator><![CDATA[Aurélien Hebert]]></dc:creator>
		<pubDate>Tue, 04 May 2021 09:15:00 +0000</pubDate>
				<category><![CDATA[Engineering]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">https://www2.cleverapps.io/wp/blog/technology/2021/05/04/how-to-deploy-apache-superset-on-clever-cloud/</guid>

					<description><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/superset-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="superset 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/08/superset-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p>At Clever Cloud we manage most of our own data and when we want to gather a particular information, we open our SQL interpreter and query all the things manually. This somehow worked because most of us are technical but it's not necessary the case anymore. So we want a nice dashboarding solution to make data available in a nicer way. This is how we came to try Superset.

<span id="more-2834"></span>

What is Superset? In their own words:
<blockquote>Superset is fast, lightweight, intuitive, and loaded with options that make it easy for users of all skill sets to explore and visualize their data.</blockquote>
You can configure different sort of visualizations from simple line charts to highly detailed geo-spatial charts and organize them in dashboard. Take a look at <a href="https://superset.apache.org/">their documentation</a> to grasp the full extent of what you can do.
<h2 id="how-to-deploy-superset">How to deploy Superset</h2>
Superset is written in Python and requires a PostgreSQL database. In Clever Cloud terms it means you will need to create a brand <a href="https://www.clever.cloud/developers/deploy/application/python/python_apps/">new Python runtime</a> with a <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/">PostgreSQL addon</a>.
<pre><code class="language-bash"># Clone last superset release
git clone --depth 1 -b 0.38.1  https://github.com/apache/superset.git

# Move in superset repository
cd superset

# Create the python application
clever create --type python Superset

# Create the PostgreSQL instance                                
clever addon create postgresql-addon --plan m SupersetPG
    
# link the addon 
clever service link-addon SupersetPG
</code></pre>
Once the application is created, edit it's information. As you need to build Superset backend and frontend, you need to enable a <a href="https://www.clever.cloud/developers/administrate/apps-management/#edit-application-configuration">dedicated build instance</a>, select the <code>L</code> one. Don't foget to save the update.
<h3 id="superset-environment">Superset environment</h3>
Set the following environment, <code>YOUR_APP_ID</code> corresponds to your own application id, <code>A_SECRET_KEY</code> is a random secret key you choose, and <code>AN_ADMIN_PASSWORD</code> will be the admin password for the superset application:
<pre><code class="language-bash"># Use gunicorn as python mode 
clever env set CC_PYTHON_BACKEND gunicorn

# Start the app using create_app() 
clever env set CC_PYTHON_MODULE superset.app:create_app()

# Python version to use
clever env set CC_PYTHON_VERSION 3.7

# Load all superset requirements
clever env set CC_PIP_REQUIREMENTS_FILE requirements/base.txt

# Application port
clever env set PORT 8080

# PYTHONPATH
clever env set PYTHONPATH /home/bas/YOUR_APP_ID/config/

# App secret key
clever env set SECRET_KEY A_SECRET_KEY

# Post build commands
clever env set CC_POST_BUILD_HOOK ./init.sh

# Superset admin password
clever env set ADMIN_PASSWORD AN_ADMIN_PASSWORD
</code></pre>
<h3 id="configure-superset">Configure superset</h3>
Superset need a local config python file. Wrote locally a <code>clever_config.py</code>:
<pre><code class="language-python">import os
# Superset specific config
ROW_LIMIT = 5000

SUPERSET_WEBSERVER_PORT = os.getenv("PORT")
SUPERSET_WEBSERVER_ADDRESS = "0.0.0.0"

# Flask App Builder configuration
# Your App secret key
SECRET_KEY = os.getenv("SECRET_KEY")

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = os.getenv("POSTGRESQL_ADDON_URI")

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
</code></pre>
<h3 id="superset-build-scipt">Superset build scipt</h3>
The next step is to write an <code>init.sh</code>file that will include all build tasks for superset:
<pre><code class="language-bash">#!/bin/bash

# Load configuration file in PYTHONPATH
mkdir $APP_HOME/config
cp clever_config.py $APP_HOME/config/superset_config.py

# Create an admin user (you will be prompted to set username, first and last name before setting a password)
superset fab create-admin \
    --username admin \
    --firstname admin \
    --lastname admin \
    --email admin@admin.com \
    --password ${ADMIN_PASSWORD}

# Upgrade the database
superset db upgrade

# Loading examples data set (optional)
superset load_examples

# Create default roles and permissions
superset init

# Build frontend
cd superset-frontend 
npm install -f --no-optional
npm run build
</code></pre>
Clever supports <a href="https://www.clever.cloud/developers/doc/develop/build-hooks/#setting-hooks-up">post build hooks</a>, this <code>init.sh</code> file will be played at the end of the build phase.

It's used to set the config file we wrote before into <code>PYTHONPATH</code> used by the application. Then it will start some superset commands required for the first start of the application (create the admin user if it doesn't exists, upgrade the database, and file it with examples and finally init the superset appication). Those superset commands could be remove of the init file after the first success build. Finally, this script is used to also build the frontend of the superset application.
<h3 id="superset-requirements">Superset requirements</h3>
When you added the <code>CC_PIP_REQUIREMENTS_FILE</code>, it told clever cloud to load custom requirement for superset which are locate in the <code>requirements/base.txt</code> file. As you are using the PostgreSQL add-on, you need to add its requirement in this base file:
<pre><code class="language-bash">echo "psycopg2&gt;=2.7 --no-binary psycopg2" &gt;&gt; requirements/base.txt
</code></pre>
The Clever Cloud python application still needs a local <code>requirements.txt</code> to start the install. Generate it with:
<pre><code class="language-bash">pip3 freeze &gt; requirements.txt 
</code></pre>
As we use gunicorn and the PostgreSQL add-on, they are required in the <code>requirements.txt</code> file, add them:
<pre><code class="language-bash">echo "psycopg2&gt;=2.7 --no-binary psycopg2" &gt;&gt; requirements.txt

# gunicorn valid versions are located in setup.py file
echo "gunicorn&gt;=20.0.2, &lt;20.1" &gt;&gt; requirements.txt
</code></pre>
<h3 id="deploy">Deploy</h3>
Deploy the superset application into Clever cloud:
<pre><code class="language-bash">chmod u+x init.sh

# Add your files
git add .

# Create the first commit
git commit -m "clever init"

# Deploy the application
clever deploy

# Run the application
clever open
</code></pre>
Once this is done you should be able to access the superset application, enjoy!

After the first successful <code>superset</code> deployement you can remove on the <code>init.sh</code> file all commands starting with superset (they are required for the first start).]]></description>
										<content:encoded><![CDATA[<p><img width="1400" height="540" src="https://cdn.clever-cloud.com/uploads/2021/08/superset-1.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="superset 1" decoding="async" loading="lazy" srcset="https://cdn.clever-cloud.com/uploads/2021/08/superset-1.jpg 1400w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-300x116.jpg 300w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-1024x395.jpg 1024w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-768x296.jpg 768w, https://cdn.clever-cloud.com/uploads/2021/08/superset-1-1368x528.jpg 1368w" sizes="auto, (max-width: 1400px) 100vw, 1400px" /></p>At Clever Cloud we manage most of our own data and when we want to gather a particular information, we open our SQL interpreter and query all the things manually. This somehow worked because most of us are technical but it's not necessary the case anymore. So we want a nice dashboarding solution to make data available in a nicer way. This is how we came to try Superset.

<span id="more-2834"></span>

What is Superset? In their own words:
<blockquote>Superset is fast, lightweight, intuitive, and loaded with options that make it easy for users of all skill sets to explore and visualize their data.</blockquote>
You can configure different sort of visualizations from simple line charts to highly detailed geo-spatial charts and organize them in dashboard. Take a look at <a href="https://superset.apache.org/">their documentation</a> to grasp the full extent of what you can do.
<h2 id="how-to-deploy-superset">How to deploy Superset</h2>
Superset is written in Python and requires a PostgreSQL database. In Clever Cloud terms it means you will need to create a brand <a href="https://www.clever.cloud/developers/deploy/application/python/python_apps/">new Python runtime</a> with a <a href="https://www.clever.cloud/developers/deploy/addon/postgresql/">PostgreSQL addon</a>.
<pre><code class="language-bash"># Clone last superset release
git clone --depth 1 -b 0.38.1  https://github.com/apache/superset.git

# Move in superset repository
cd superset

# Create the python application
clever create --type python Superset

# Create the PostgreSQL instance                                
clever addon create postgresql-addon --plan m SupersetPG
    
# link the addon 
clever service link-addon SupersetPG
</code></pre>
Once the application is created, edit it's information. As you need to build Superset backend and frontend, you need to enable a <a href="https://www.clever.cloud/developers/administrate/apps-management/#edit-application-configuration">dedicated build instance</a>, select the <code>L</code> one. Don't foget to save the update.
<h3 id="superset-environment">Superset environment</h3>
Set the following environment, <code>YOUR_APP_ID</code> corresponds to your own application id, <code>A_SECRET_KEY</code> is a random secret key you choose, and <code>AN_ADMIN_PASSWORD</code> will be the admin password for the superset application:
<pre><code class="language-bash"># Use gunicorn as python mode 
clever env set CC_PYTHON_BACKEND gunicorn

# Start the app using create_app() 
clever env set CC_PYTHON_MODULE superset.app:create_app()

# Python version to use
clever env set CC_PYTHON_VERSION 3.7

# Load all superset requirements
clever env set CC_PIP_REQUIREMENTS_FILE requirements/base.txt

# Application port
clever env set PORT 8080

# PYTHONPATH
clever env set PYTHONPATH /home/bas/YOUR_APP_ID/config/

# App secret key
clever env set SECRET_KEY A_SECRET_KEY

# Post build commands
clever env set CC_POST_BUILD_HOOK ./init.sh

# Superset admin password
clever env set ADMIN_PASSWORD AN_ADMIN_PASSWORD
</code></pre>
<h3 id="configure-superset">Configure superset</h3>
Superset need a local config python file. Wrote locally a <code>clever_config.py</code>:
<pre><code class="language-python">import os
# Superset specific config
ROW_LIMIT = 5000

SUPERSET_WEBSERVER_PORT = os.getenv("PORT")
SUPERSET_WEBSERVER_ADDRESS = "0.0.0.0"

# Flask App Builder configuration
# Your App secret key
SECRET_KEY = os.getenv("SECRET_KEY")

# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = os.getenv("POSTGRESQL_ADDON_URI")

# Flask-WTF flag for CSRF
WTF_CSRF_ENABLED = True
# Add endpoints that need to be exempt from CSRF protection
WTF_CSRF_EXEMPT_LIST = []
# A CSRF token that expires in 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365

# Set this API key to enable Mapbox visualizations
MAPBOX_API_KEY = ''
</code></pre>
<h3 id="superset-build-scipt">Superset build scipt</h3>
The next step is to write an <code>init.sh</code>file that will include all build tasks for superset:
<pre><code class="language-bash">#!/bin/bash

# Load configuration file in PYTHONPATH
mkdir $APP_HOME/config
cp clever_config.py $APP_HOME/config/superset_config.py

# Create an admin user (you will be prompted to set username, first and last name before setting a password)
superset fab create-admin \
    --username admin \
    --firstname admin \
    --lastname admin \
    --email admin@admin.com \
    --password ${ADMIN_PASSWORD}

# Upgrade the database
superset db upgrade

# Loading examples data set (optional)
superset load_examples

# Create default roles and permissions
superset init

# Build frontend
cd superset-frontend 
npm install -f --no-optional
npm run build
</code></pre>
Clever supports <a href="https://www.clever.cloud/developers/doc/develop/build-hooks/#setting-hooks-up">post build hooks</a>, this <code>init.sh</code> file will be played at the end of the build phase.

It's used to set the config file we wrote before into <code>PYTHONPATH</code> used by the application. Then it will start some superset commands required for the first start of the application (create the admin user if it doesn't exists, upgrade the database, and file it with examples and finally init the superset appication). Those superset commands could be remove of the init file after the first success build. Finally, this script is used to also build the frontend of the superset application.
<h3 id="superset-requirements">Superset requirements</h3>
When you added the <code>CC_PIP_REQUIREMENTS_FILE</code>, it told clever cloud to load custom requirement for superset which are locate in the <code>requirements/base.txt</code> file. As you are using the PostgreSQL add-on, you need to add its requirement in this base file:
<pre><code class="language-bash">echo "psycopg2&gt;=2.7 --no-binary psycopg2" &gt;&gt; requirements/base.txt
</code></pre>
The Clever Cloud python application still needs a local <code>requirements.txt</code> to start the install. Generate it with:
<pre><code class="language-bash">pip3 freeze &gt; requirements.txt 
</code></pre>
As we use gunicorn and the PostgreSQL add-on, they are required in the <code>requirements.txt</code> file, add them:
<pre><code class="language-bash">echo "psycopg2&gt;=2.7 --no-binary psycopg2" &gt;&gt; requirements.txt

# gunicorn valid versions are located in setup.py file
echo "gunicorn&gt;=20.0.2, &lt;20.1" &gt;&gt; requirements.txt
</code></pre>
<h3 id="deploy">Deploy</h3>
Deploy the superset application into Clever cloud:
<pre><code class="language-bash">chmod u+x init.sh

# Add your files
git add .

# Create the first commit
git commit -m "clever init"

# Deploy the application
clever deploy

# Run the application
clever open
</code></pre>
Once this is done you should be able to access the superset application, enjoy!

After the first successful <code>superset</code> deployement you can remove on the <code>init.sh</code> file all commands starting with superset (they are required for the first start).]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
