pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[DISCUSS]PIP-222: Add CommandPartitionedTopicMetadata metrics

Open tjiuming opened this issue 3 years ago • 0 comments

Motivation

Currently, there's no way to track CommandPartitionedTopicMetadata requests. There's no metrics that indicate that a broker is handling CommandPartitionedTopicMetadata requests.

Misconfigured clients might flood brokers with CommandPartitionedTopicMetadata requests and cause high CPU consumption.

Goal

  1. Provide pulsar_broker_command_execution_latency metric
  2. Provide pulsar_broker_command_execution_failed metric

API Changes

No response

Implementation

  1. Initialize a Histogram instance in ServerCnx.java to record the command execution latency

    private static final Histogram COMMAND_EXECUTION_LATENCY = Histogram
            .build("pulsar_broker_command_execution_latency", "-")
            .unit("ms")
            .labelNames("command")
            .buckets(1, 10, 50, 100, 200, 500, 1000, 2000)
            .register();
    

    The instance has the following labels: a. cluster: The name of the cluster b. command: The name of the command

  2. Initialize a Counter instance in ServerCnx.java to record the command execution failed ops

    private static final Counter COMMAND_EXECUTION_FAILED = Counter
            .build("pulsar_broker_command_execution_failed", "-")
            .labelNames("command", "code")
            .register();
    

    The instance has the following labels: a. cluster: The name of the cluster b. command: The name of the command c. code: The command execution failed reason, see ServerError

Alternatives

No response

Anything else?

Related issue link: https://github.com/apache/pulsar/issues/18243

tjiuming avatar Nov 03 '22 10:11 tjiuming