<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="https://zhenik.github.io/https://zhenik.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://zhenik.github.io/https://zhenik.github.io/" rel="alternate" type="text/html" /><updated>2023-09-20T15:58:35+00:00</updated><id>https://zhenik.github.io/https://zhenik.github.io/feed.xml</id><title type="html">Nikita Zhevnitskiy</title><subtitle>dev &amp; just a guy</subtitle><entry><title type="html">Testing Kafka based applications</title><link href="https://zhenik.github.io/https://zhenik.github.io/testing-kafka-based-applications/" rel="alternate" type="text/html" title="Testing Kafka based applications" /><published>2019-06-24T00:00:00+00:00</published><updated>2019-06-24T00:00:00+00:00</updated><id>https://zhenik.github.io/https://zhenik.github.io/testing-kafka-based-applications</id><content type="html" xml:base="https://zhenik.github.io/https://zhenik.github.io/testing-kafka-based-applications/">&lt;p&gt;Blog post about &lt;a href=&quot;https://medium.com/test-kafka-based-applications/https-medium-com-testing-kafka-based-applications-85d8951cec43?sk=b5a54ca1cedcaeac9ece529436874230&quot;&gt;Testing kafka based applications&lt;/a&gt;
Different approaches how to make Unit, integration and end-to-end tests.&lt;br /&gt;
—-
&lt;a href=&quot;https://github.com/sysco-middleware/kafka-testing&quot;&gt;https://github.com/sysco-middleware/kafka-testing&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;</content><author><name></name></author><summary type="html">Blog post about Testing kafka based applications Different approaches how to make Unit, integration and end-to-end tests. —- https://github.com/sysco-middleware/kafka-testing</summary></entry><entry><title type="html">Kafka client’s metrics &amp;amp; prometheus</title><link href="https://zhenik.github.io/https://zhenik.github.io/kafka-metrics-prometheus/" rel="alternate" type="text/html" title="Kafka client’s metrics &amp;amp; prometheus" /><published>2019-04-08T00:00:00+00:00</published><updated>2019-04-08T00:00:00+00:00</updated><id>https://zhenik.github.io/https://zhenik.github.io/kafka-metrics-prometheus</id><content type="html" xml:base="https://zhenik.github.io/https://zhenik.github.io/kafka-metrics-prometheus/">&lt;p&gt;Proof of concept: &lt;a href=&quot;https://github.com/prometheus/jmx_exporter&quot;&gt;jmx-exporter&lt;/a&gt; and kafka clients.
Main idea: expose &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JMX metrics&lt;/code&gt; of applications which use Apache Kafka APIs.
Jmx exporter requires &lt;a href=&quot;https://github.com/prometheus/jmx_exporter/tree/master/example_configs&quot;&gt;config patterns&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/zhenik/kafka-clients_metrics-tracing&quot;&gt;https://github.com/zhenik/kafka-clients_metrics-tracing&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;approaches&quot;&gt;Approaches:&lt;/h2&gt;
&lt;h3 id=&quot;1-application-coupled-with-java-agent-this-approach-sort-of-standalone-mode-reference&quot;&gt;1. Application coupled with java agent. This approach sort of standalone mode. &lt;a href=&quot;https://github.com/prometheus/jmx_exporter#jmx-exporter&quot;&gt;Reference&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/zhenik/kafka-clients_metrics-tracing/master/docs/jmx-exporter-standalone.png&quot; alt=&quot;img&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;2-application--exporterside-car&quot;&gt;2. Application + Exporter(side-car).&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/zhenik/kafka-clients_metrics-tracing/master/docs/jmx-exporter-decoupled.png&quot; alt=&quot;img&quot; /&gt;&lt;br /&gt;
There is need to run application with several parameters to be able expose JMX metrics from application. 
Here I provide &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Dockerfile&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;env&lt;/code&gt; variables:&lt;/p&gt;
&lt;div class=&quot;language-dockerfile highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;FROM&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; openjdk:8-jdk-stretch&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;COPY&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; ./target/producer-metrics-1.0-SNAPSHOT.jar .&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;CMD&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; java -Dcom.sun.management.jmxremote \&lt;/span&gt;
           -Dcom.sun.management.jmxremote=true \
           -Dcom.sun.management.jmxremote.local.only=false \
           -Dcom.sun.management.jmxremote.authenticate=false \
           -Dcom.sun.management.jmxremote.ssl=false \
           -Djava.rmi.server.hostname=$HOST \
           -Dcom.sun.management.jmxremote.host=$HOST \
           -Dcom.sun.management.jmxremote.port=$JMX_PORT \
           -Dcom.sun.management.jmxremote.rmi.port=$JMX_PORT \
           -jar producer-metrics-1.0-SNAPSHOT.jar kafka:9092
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;3-application-on-dropwizard-with-custom-metrics--exporterside-car&quot;&gt;3. Application on Dropwizard with custom metrics + Exporter(side-car)&lt;/h3&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/zhenik/kafka-clients_metrics-tracing/master/docs/jmx-exporter-custom-metrics.png&quot; alt=&quot;img&quot; /&gt;
To expand metrics I use &lt;a href=&quot;https://www.dropwizard.io/1.3.9/docs/&quot;&gt;Dropwizard&lt;/a&gt; framework and &lt;a href=&quot;https://github.com/prometheus/client_java/tree/master/simpleclient_dropwizard&quot;&gt;prometheus client for dropwizard&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-java highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// Create registry for Dropwizard metrics.&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;MetricRegistry&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;MetricRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Create a Dropwizard counter.&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;Counter&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;my_custom_counter_total&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;nc&quot;&gt;CollectorRegistry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;defaultRegistry&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;register&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;DropwizardExports&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;));&lt;/span&gt;

&lt;span class=&quot;cm&quot;&gt;/** prometheus + dropwizard metrics are available 
*   on localhost:8081/prometheus/metrics
*/&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;getAdminContext&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;ServletHolder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;MetricsServlet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;/prometheus/metrics&quot;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// Add metrics about CPU, JVM memory etc.&lt;/span&gt;
&lt;span class=&quot;nc&quot;&gt;DefaultExports&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;initialize&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;// use &lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;counter&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;inc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">Proof of concept: jmx-exporter and kafka clients. Main idea: expose JMX metrics of applications which use Apache Kafka APIs. Jmx exporter requires config patterns.</summary></entry></feed>