Skip to content

Instantly share code, notes, and snippets.

@n1ko-w1ll
n1ko-w1ll / kafkaToInflux.scala
Created November 20, 2019 14:23
Akka streams snippet on how to read several messages from Kafka and write the content to InfluxDB
val committerSettings = CommitterSettings.create(system)
val innerControl = new AtomicReference[Consumer.Control](Consumer.NoopControl)
val stream = RestartSource.withBackoff(
minBackoff = 3.seconds,
maxBackoff = 30.seconds,
randomFactor = 0.2,
) { () =>
Consumer
.committableSource(consumerSettings, Subscriptions.topics(topic))

Kafka command line tools

If JMX_PORT is specified, the command line tools are exited with the following exception:

Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 5555

use unset JMX_PORT to unset the port and make the tools work.

Topics

@n1ko-w1ll
n1ko-w1ll / akka_grafana_prometheus_dashboard.json
Created January 22, 2018 14:50
This is a Grafana dashboard for visualizing akka metrics collected with Kamon and scraped by Prometheus.
{
"__inputs": [
{
"name": "DS_PROMETHEUS",
"label": "Prometheus",
"description": "",
"type": "datasource",
"pluginId": "prometheus",
"pluginName": "Prometheus"
}
@n1ko-w1ll
n1ko-w1ll / jmx-monitoring.yml
Created January 10, 2018 13:55
Apache ActiveMQ Artemis 2.x JMX Exporter Example Configuration
---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: "^org.apache.activemq.artemis<broker=\"([^\"]*)\"><>([^:]*):\\s(.*)"
attrNameSnakeCase: true
name: artemis_$2
type: COUNTER
labels:
host: $1
@n1ko-w1ll
n1ko-w1ll / StreamProcessor.java
Last active November 10, 2017 16:13
Akka Stream Processor - destilled example out of a real world project that demonstrates how to persist the event offset together with the serialized AtLeastOnceDeliverySnapshot
import com.google.protobuf.ByteString;
import akka.actor.Props;
import akka.event.DiagnosticLoggingAdapter;
import akka.event.Logging;
import akka.japi.pf.ReceiveBuilder;
import akka.persistence.AbstractPersistentActorWithAtLeastOnceDelivery;
import akka.persistence.AtLeastOnceDelivery;
import akka.persistence.RecoveryCompleted;
import akka.persistence.SaveSnapshotFailure;

Keybase proof

I hereby claim:

  • I am n1ko-w1ll on github.
  • I am n1ko_w1ll (https://keybase.io/n1ko_w1ll) on keybase.
  • I have a public key ASBm9efEGiE5WVcbOuTKy-Qr1Qk1ZSyA7Iz4KHy1Rwol1go

To claim this, I am signing this object: