<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Russ Miles</title>
    <description>The latest articles on DEV Community by Russ Miles (@russmiles).</description>
    <link>https://dev.to/russmiles</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F628883%2F35af3588-2791-4d1b-a6b8-7c4d65d37bd1.jpeg</url>
      <title>DEV Community: Russ Miles</title>
      <link>https://dev.to/russmiles</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/russmiles"/>
    <language>en</language>
    <item>
      <title>Observing the Reliability of your Java Apps and Services with Spring Boot, Micrometer, Prometheus &amp; Reliably</title>
      <dc:creator>Russ Miles</dc:creator>
      <pubDate>Wed, 04 Aug 2021 14:49:16 +0000</pubDate>
      <link>https://dev.to/reliably/observing-the-reliability-of-your-java-apps-and-services-with-spring-boot-micrometer-prometheus-reliably-27od</link>
      <guid>https://dev.to/reliably/observing-the-reliability-of-your-java-apps-and-services-with-spring-boot-micrometer-prometheus-reliably-27od</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F9216%2F1%2Abd7UX4O4EL3clA4mFxeLEw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F9216%2F1%2Abd7UX4O4EL3clA4mFxeLEw.jpeg" alt="Photo by [Marten Newhall](https://unsplash.com/@laughayette?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText) on [Unsplash](https://unsplash.com/s/photos/magnifying-glass?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here at Reliably we are huge fans of &lt;a href="https://spring.io/projects/spring-boot" rel="noopener noreferrer"&gt;Spring Boot&lt;/a&gt; and the &lt;a href="https://micrometer.io" rel="noopener noreferrer"&gt;Micrometer&lt;/a&gt; dimensional metrics instrumentation library for providing the rich set of possible metrics that can be a great foundation for the Service Level Indicators that provide coverage for your &lt;a href="https://reliably.com/docs/getting-started/slos/" rel="noopener noreferrer"&gt;Reliably Service Level Objectives as Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As of Spring Boot 2.0, Micrometer became the default instrumentation library for the huge range of Spring Boot applications, from monoliths to microservices. With Micrometer bakes in by default, we started to explore just how easy it would be to bring Reliably's "Developer-First" SLOs to bear on your Spring Boot apps and services.&lt;/p&gt;

&lt;p&gt;In this article we share our findings including how Reliably really can work "Bootifully" (TM, Josh Long :) ) with all your Spring Boot apps and services, out of the box and with no extra code required!&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: The full coded sample for this article is &lt;a href="https://github.com/Lawouach/spring-boot-prometheus-reliably" rel="noopener noreferrer"&gt;available on GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Setup: Spring Boot, Prometheus &amp;amp; Reliably
&lt;/h2&gt;

&lt;p&gt;The exercise we wanted to conduct was to show how you could define and collaborate on Reliably Service Level Objectives that were measuring the availability of a simple Spring Boot service. To do this we needed three pieces in the mix:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3576%2F1%2A6E8cWoNwVH_ogyCjZml-lw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F3576%2F1%2A6E8cWoNwVH_ogyCjZml-lw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this approach, Spring Boot and Micrometer would push dimensional metrics to Prometheus. Then Reliably would use Prometheus queries to collate Service Level Indicators to back the Service Level Objectives being observed. Simple? Actually, it is…&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;NOTE: We chose Prometheus for this particular article but we could just have easily picked one of the other tools supported by Micrometer and Reliably, such as &lt;a href="https://dev.to/reliably/bringing-reliability-closer-to-you-with-reliably-and-datadog-2jbm"&gt;DataDog&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Sourcing Metrics from our Spring Boot Service
&lt;/h2&gt;

&lt;p&gt;To get things built as quickly and easily as possible, we used the &lt;a href="https://start.spring.io" rel="noopener noreferrer"&gt;Spring Initializr&lt;/a&gt; to generate a very simple HTTP-based application that did nothing more than provide a default root / response of "Greetings from Spring Boot!" to provide the service that we'd look to observe our SLOs on.&lt;/p&gt;

&lt;p&gt;As mentioned in the introduction, by default Spring Boot applications come with all the power of Micrometer by default, the only thing we needed to do was make sure that our Spring Boot service's metrics could be scraped by Prometheus by adding a single line to our service's application.properties:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;h2&gt;
  
  
  Setting up Prometheus to Scrape the Metrics
&lt;/h2&gt;

&lt;p&gt;Next we added a simple Scraper configuration to our instance of Prometheus to periodically grab all the Micrometer metrics for our Spring Boot service from the endpoint we configured in the previous step:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
With this config in place, Prometheus will grab the metrics from our Spring Boot service every 15 seconds.
&lt;h2&gt;
  
  
  Creating and Observing the Reliably SLOs as Code
&lt;/h2&gt;

&lt;p&gt;The final step was for us to use the new Prometheus support in the Reliably CLI v0.23.0 to create our SLO with an SLI implemented as an appropriate Prometheus query:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;This SLO definition includes a Service Level Indicator (SLI) that queries Prometheus for the appropriate metrics to help us judge that the SLO is being met, or not. &lt;/p&gt;

&lt;h2&gt;
  
  
  Pushing your SLIs to Reliably
&lt;/h2&gt;

&lt;p&gt;With your Service Level Objective, and corresponding Prometheus-driven Service Level Indicators, in hand, you can now begin pushing the SLO and SLIs over time to Reliably using the &lt;code&gt;reliably slo agent&lt;/code&gt; command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;reliably slo agent &lt;span class="nt"&gt;-i&lt;/span&gt; 10
INFO[0000] &lt;span class="nt"&gt;---&lt;/span&gt; starting slo indicator agent &lt;span class="nt"&gt;---&lt;/span&gt;         
INFO[0000] getting indicators &lt;span class="k"&gt;for &lt;/span&gt;objective: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'99% of requests return 2xx over last 1 hour'&lt;/span&gt;, &lt;span class="nv"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'my spring boot app'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; 
INFO[0000] indicator percent: &lt;span class="o"&gt;[&lt;/span&gt;98.91] &lt;span class="k"&gt;for &lt;/span&gt;objective: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'99% of requests return 2xx over last 1 hour'&lt;/span&gt;, &lt;span class="nv"&gt;service&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'my spring boot app'&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Observing your SLOs from your Command Line
&lt;/h2&gt;

&lt;p&gt;With our Spring Boot service running and receiving requests, our Prometheus instance scraping the available metrics, and Reliably monitoring the above SLO, we have successfully defined and can observe a Java Spring Boot application's reliability with as little code as possible! The final step is to observe the status of your SLO using the &lt;code&gt;reliably slo report -w -m reliably.yaml&lt;/code&gt; command:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwnnrp67vr9amv07re8c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwnnrp67vr9amv07re8c.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go next: We need … You!
&lt;/h2&gt;

&lt;p&gt;Our goal is to shift reliability left by making it as easy as possible for you and your team to be able to define, observe and learn how to make your system's reliable.  As such we are constantly looking to make it easier for people to collaborate, code and observe Service Level Objectives and Indicators for their own bespoke needs. &lt;/p&gt;

&lt;p&gt;You can check out all the different tools that we currently integrate with in &lt;a href="https://reliably.com/docs/" rel="noopener noreferrer"&gt;our docs&lt;/a&gt;, but if there's something you don't see then please &lt;a href="https://reliably.com/contact/" rel="noopener noreferrer"&gt;get in touch&lt;/a&gt; or maybe even raise a ticket and PR yourself on our &lt;a href="https://github.com/reliablyhq/cli" rel="noopener noreferrer"&gt;free and open source Reliably CLI project&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>sre</category>
      <category>prometheus</category>
      <category>spring</category>
    </item>
  </channel>
</rss>
