Menu
Grafana Cloud

NSQ integration for Grafana Cloud

NSQ is a realtime distributed messaging platform designed to operate at scale, handling billions of messages per day.

This integration uses NSQ statsd integration to gather metrics.

This integration includes 2 useful alerts and 2 pre-built dashboards to help monitor and visualize NSQ metrics.

Before you begin

In order for the integration to work, point nsqd to Grafana Alloy statsd exporter with -statsd-address, using nsqd command line flags, like this:

nsqd -statsd-address=agent.default.svc.cluster.local:9125

To enable e2e metrics with extra flags:

nsqd -e2e-processing-latency-percentile=1.0,0.99,0.95 -e2e-processing-latency-window-time=1m0s

To learn more, see end-to-end processing latency in nsq.

Install NSQ integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find NSQ and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send NSQ metrics to your Grafana Cloud instance.
  4. Click Install to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your NSQ setup.

Configuration snippets for Grafana Alloy

Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your NSQ instances, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

Advanced integrations snippets

alloy
prometheus.exporter.statsd "integrations_statsd_exporter" {
  mapping_config_path = "statsd_mapping.yaml"
}

discovery.relabel "integrations_statsd_exporter" {
	targets = prometheus.exporter.statsd.integrations_statsd_exporter.targets

	rule {
		target_label = "job"
		replacement  = "integrations/statsd_exporter"
	}
}

prometheus.scrape "integrations_statsd_exporter" {
	targets    = discovery.relabel.integrations_statsd_exporter.output
	forward_to = [prometheus.relabel.integrations_statsd_exporter.receiver]
	job_name   = "integrations/statsd_exporter"
}

prometheus.relabel "integrations_statsd_exporter" {
	forward_to = [prometheus.remote_write.metrics_service.receiver]

	rule {
		source_labels = ["exported_job"]
		target_label  = "job"
		replacement   = "integrations/$1"
	}

	rule {
		source_labels = ["exported_instance"]
		target_label  = "instance"
	}

	rule {
		regex  = "(exported_instance|exported_job)"
		action = "labeldrop"
	}
}

This integrations uses the prometheus.exporter.statsd component to generate metrics from a NSQ instance.

The statsd exporter component requires an external mapping configuration file. You can download the correct mapping file for this integration here.

For the full array of configuration options, refer to the prometheus.exporter.statsd component reference documentation.

This exporter must be linked with a discovery.relabel component to apply the necessary relabelings.

For each NSQ instance to be monitored you must create a pair of these components.

Configure the following properties within each discovery.relabel component:

  • instance label: constants.hostname sets the instance label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this NSQ instance.

You can then scrape them by including each discovery.relabel under targets within the prometheus.scrape component.

Grafana Agent static configuration (deprecated)

The following section shows configuration for running Grafana Agent in static mode which is deprecated. You should use Grafana Alloy for all new deployments.

Dashboards

The NSQ integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

  • NSQ Instances
  • NSQ Topics

NSQ topics dashboard

NSQ topics dashboard

NSQ instances dashboard

NSQ instances dashboard

Alerts

The NSQ integration includes the following useful alerts:

AlertDescription
NsqTopicDepthIncreasingCritical: Topic depth is increasing.
NsqChannelDepthIncreasingCritical: Topic channel depth is increasing.

Metrics

The most important metrics provided by the NSQ integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

  • nsq_mem_gc_pause_usec_100
  • nsq_mem_gc_pause_usec_95
  • nsq_mem_gc_pause_usec_99
  • nsq_mem_heap_idle_bytes
  • nsq_mem_heap_in_use_bytes
  • nsq_mem_heap_objects
  • nsq_mem_heap_released_bytes
  • nsq_mem_next_gc_bytes
  • nsq_topic_backend_depth
  • nsq_topic_channel_backend_depth
  • nsq_topic_channel_clients
  • nsq_topic_channel_deferred_count
  • nsq_topic_channel_depth
  • nsq_topic_channel_e2e_processing_latency_99
  • nsq_topic_channel_in_flight_count
  • nsq_topic_channel_message_count
  • nsq_topic_channel_requeue_count
  • nsq_topic_channel_timeout_count
  • nsq_topic_depth
  • nsq_topic_e2e_processing_latency_99
  • nsq_topic_message_bytes
  • nsq_topic_message_count
  • up

Changelog

md
# 0.0.2 - September 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.

# 0.0.1 - January 2022

* Initial release

Cost

By connecting your NSQ instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.