Introduction

Blink offsers a way to monitor the performance of the Blink instance using metrics. In this article, we will walk you through how to use metrics in Blink.

Metrics in Blink can be one of the following types:

  • InfluxDB metrics
  • Prometheus metrics

Even if you don’t use any provider for metrics - Blink still keeps track of the metrics and shows them in the logs every few seconds.

You can see the example below

2024-05-13 11:55:27 INFO Stream: Messages stat messages_received=60 messages_sent=4 messages_dropped_or_filtered=56

Available metrics

In case you want to understand the performance of the Blink instance, you can take a look at the metrics provided by pipeline and its processors. It will be helpful to indentify the bottlenecks in the pipeline and optimize the performance.

Pipeline metrics

Pipeline provides a few general metrics that help you to understand the performance of the pipeline. Here is the list of metrics that the pipeline provides:

received_messages
number

Number of messages received by the pipeline from the source

sent_messages
number

Number of messages send to the downstream by the pipeline

sink_errors
number

Number of errors that occurred in the sink. Usually happens when Blink can’t write the data to the destination.

Processor metrics

Each processor provides the same group of metrics that help you to understand the performance of the processor. Here is the list of metrics that each processor provides:

dropped_messages
number

The number of messages dropped by the pipeline. Dropped messages are the messages that the pipeline filtered by the processors. For example, if you have a processor that filters out the messages that contain the word error, the number of messages that contain the word error will be counted as dropped messages.

execution_time
number

The time it takes to execute the processor.

sent_messages
number

Number of messages processed by the processor and sent it to the next processor or sink

received_messages
number

Number of messages received by the processor from the source or previous processor

Using InfluxDB metrics

In order to use InfluxDB metrics, you need to define the InfluxDB URI in the configuration file. Here is an example of how to define the InfluxDB URI in the configuration file (this is partial config file. It doesn’t contain all the properties):

service:
  influx:
    host: #{secret.influxdb/host}
    token: #{secret.influxdb/token}
    org: #{secret.influxdb/org}
    bucket: #{secret.influxdb/bucket}
    group_name: #{secret.influxdb/group_name}
    pipeline_id: #{secret.influxdb/pipeline_id}

Prometheus metrics

Prometheus metrics are enabled by default. You can access the metrics by visiting the /metrics endpoint of the Blink instance. By defult Blink starts HTTP server is disabled. But you can enable it on port :3333 by setting starting Blink with -s true flag.

blink start -c config.yaml -s true

But you can also access the metrics by visiting the /metrics endpoint of the Blink instance. Here is an example of how to access the metrics:

curl http://localhost:3333/metrics

Promehteus metrics are exposed in the following format:

# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 3.3166e-05
go_gc_duration_seconds{quantile="0.25"} 3.3166e-05
go_gc_duration_seconds{quantile="0.5"} 4.9166e-05
go_gc_duration_seconds{quantile="0.75"} 4.9166e-05
go_gc_duration_seconds{quantile="1"} 4.9166e-05
go_gc_duration_seconds_sum 8.2332e-05
go_gc_duration_seconds_count 2
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 16
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.22.1"} 1
# HELP go_memstats_alloc_bytes Number of bytes allocated and still in use.
# TYPE go_memstats_alloc_bytes gauge
go_memstats_alloc_bytes 1.1489904e+07
# HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed.
# TYPE go_memstats_alloc_bytes_total counter
go_memstats_alloc_bytes_total 1.21782e+07
# HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table.
# TYPE go_memstats_buck_hash_sys_bytes gauge
go_memstats_buck_hash_sys_bytes 1.460935e+06
# HELP go_memstats_frees_total Total number of frees.
# TYPE go_memstats_frees_total counter
go_memstats_frees_total 7742
# HELP go_memstats_gc_cpu_fraction The fraction of this program's available CPU time used by the GC since the program started.
# TYPE go_memstats_gc_cpu_fraction gauge
go_memstats_gc_cpu_fraction 0.05779912883230022
# HELP go_memstats_gc_sys_bytes Number of bytes used for garbage collection system metadata.
# TYPE go_memstats_gc_sys_bytes gauge
go_memstats_gc_sys_bytes 3.190296e+06
# HELP go_memstats_heap_alloc_bytes Number of heap bytes allocated and still in use.
# TYPE go_memstats_heap_alloc_bytes gauge
go_memstats_heap_alloc_bytes 1.1489904e+07
# HELP go_memstats_heap_idle_bytes Number of heap bytes waiting to be used.
# TYPE go_memstats_heap_idle_bytes gauge
go_memstats_heap_idle_bytes 2.33472e+06
# HELP go_memstats_heap_inuse_bytes Number of heap bytes that are in use.
# TYPE go_memstats_heap_inuse_bytes gauge
go_memstats_heap_inuse_bytes 1.3623296e+07
# HELP go_memstats_heap_objects Number of allocated objects.
# TYPE go_memstats_heap_objects gauge
go_memstats_heap_objects 44890
# HELP go_memstats_heap_released_bytes Number of heap bytes released to OS.
# TYPE go_memstats_heap_released_bytes gauge
go_memstats_heap_released_bytes 2.33472e+06
# HELP go_memstats_heap_sys_bytes Number of heap bytes obtained from system.
# TYPE go_memstats_heap_sys_bytes gauge
go_memstats_heap_sys_bytes 1.5958016e+07
# HELP go_memstats_last_gc_time_seconds Number of seconds since 1970 of last garbage collection.
# TYPE go_memstats_last_gc_time_seconds gauge
go_memstats_last_gc_time_seconds 1.7156327317978072e+09
# HELP go_memstats_lookups_total Total number of pointer lookups.
# TYPE go_memstats_lookups_total counter
go_memstats_lookups_total 0
# HELP go_memstats_mallocs_total Total number of mallocs.
# TYPE go_memstats_mallocs_total counter
go_memstats_mallocs_total 52632
# HELP go_memstats_mcache_inuse_bytes Number of bytes in use by mcache structures.
# TYPE go_memstats_mcache_inuse_bytes gauge
go_memstats_mcache_inuse_bytes 9600
# HELP go_memstats_mcache_sys_bytes Number of bytes used for mcache structures obtained from system.
# TYPE go_memstats_mcache_sys_bytes gauge
go_memstats_mcache_sys_bytes 15600
# HELP go_memstats_mspan_inuse_bytes Number of bytes in use by mspan structures.
# TYPE go_memstats_mspan_inuse_bytes gauge
go_memstats_mspan_inuse_bytes 188320
# HELP go_memstats_mspan_sys_bytes Number of bytes used for mspan structures obtained from system.
# TYPE go_memstats_mspan_sys_bytes gauge
go_memstats_mspan_sys_bytes 195840
# HELP go_memstats_next_gc_bytes Number of heap bytes when next garbage collection will take place.
# TYPE go_memstats_next_gc_bytes gauge
go_memstats_next_gc_bytes 1.695672e+07
# HELP go_memstats_other_sys_bytes Number of bytes used for other system allocations.
# TYPE go_memstats_other_sys_bytes gauge
go_memstats_other_sys_bytes 1.315385e+06
# HELP go_memstats_stack_inuse_bytes Number of bytes in use by the stack allocator.
# TYPE go_memstats_stack_inuse_bytes gauge
go_memstats_stack_inuse_bytes 819200
# HELP go_memstats_stack_sys_bytes Number of bytes obtained from system for stack allocator.
# TYPE go_memstats_stack_sys_bytes gauge
go_memstats_stack_sys_bytes 819200
# HELP go_memstats_sys_bytes Number of bytes obtained from system.
# TYPE go_memstats_sys_bytes gauge
go_memstats_sys_bytes 2.2955272e+07
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
go_threads 13
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 0
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
# HELP received_messages The total number of messages received by source plugin
# TYPE received_messages counter
received_messages 3
# HELP sent_messages The total number of messages send to the sink plugin
# TYPE sent_messages counter
sent_messages 0
# HELP sink_errors The total number of messages that were failed to be sent to sink
# TYPE sink_errors counter
sink_errors 0
# HELP source_errors The total number of errors from source connector
# TYPE source_errors counter
source_errors 0
# HELP sql_dropped_messages Messages that were dropped, filtered by the processor
# TYPE sql_dropped_messages counter
sql_dropped_messages 3
# HELP sql_execution_time Time taken to process message
# TYPE sql_execution_time gauge
sql_execution_time 0
# HELP sql_received_messages The total number of messages send to the sink plugin
# TYPE sql_received_messages counter
sql_received_messages 3
# HELP sql_sent_messages The total number of messages send to the next sink/processor plugin
# TYPE sql_sent_messages counter
sql_sent_messages 3