.. _cloud-monitoring-lag: Monitoring Consumer Lag ======================= You can monitor consumer lag with |ccloud| using the methods described in this document. .. contents:: :local: Monitor Offset Lag via Java Client Metrics ------------------------------------------ You can monitor the ``records-lag-max`` metric from the :ref:`Java consumer `. Monitor Consumer Latency via Client Interceptors ------------------------------------------------ You can use :ref:`control_center` to track consumer latency and more. Monitor Offset Lag via Broker APIs ---------------------------------- You can also get offsets from the brokers. This section assumes that you have |ccloud| CLI installed or can copy the same properties generates in ``~/ccloud/config``. Prerequisites .. include:: ../connect/includes/installation.rst :start-line: 2 :end-line: 5 - |cp| is :ref:`installed ` #. Comment out the request time out in the |ccloud| config (``~/ccloud/config``). This line prevents the |ccloud| CLI commands from waiting too long before giving up on errors but conflicts with other settings for this use case. .. code:: bash #request.timeout.ms=20000 #. Set the ``BOOTSTRAP_SERVERS`` variable to the broker list value that was provided when you signed up. You can find this value in ``~/.ccloud/config`` or by clicking **Client config** from the |ccloud| web interface. .. code:: bash $ BOOTSTRAP_SERVERS="SASL_SSL://, , " #. From the |cp| installation home, list the consumer groups: .. code:: bash $ ./bin/kafka-consumer-groups --bootstrap-server ${BOOTSTRAP_SERVERS} --command-config \ ~/.ccloud/config --list _confluent-healthcheck example-group #. For each consumer group, check its offsets using this command. This command only shows information about consumers that use the Java consumer API (i.e., non-|zk|-based consumers). .. code:: bash $ ./bin/kafka-consumer-groups --bootstrap-server ${BOOTSTRAP_SERVERS} \ --command-config ~/.ccloud/config --describe --group _confluent-healthcheck Your output should resemble: .. code:: bash TOPIC PARTITION CURRENT-OFFSET LOG-END-OFFSET LAG CONSUMER-ID HOST CLIENT-ID _confluent-healthcheck 0 13164704 13164773 69 healthcheck-agent-bf8d1655-63a6-4061-b680-0f11cdf182e5/100.96.67.0 healthcheck-agent _confluent-healthcheck 1 13161581 13161650 69 healthcheck-agent-bf8d1655-63a6-4061-b680-0f11cdf182e5/100.96.67.0 healthcheck-agent _confluent-healthcheck 2 12229509 12229578 69 healthcheck-agent-bf8d1655-63a6-4061-b680-0f11cdf182e5/100.96.67.0 healthcheck-agent _confluent-healthcheck 3 86 86 0 healthcheck-agent-bf8d1655-63a6-4061-b680-0f11cdf182e5/100.96.67.0 healthcheck-agent ... The fourth column shows the lag, the difference between the last committed offset and the latest offset in the log.