Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Add details for Topics and Consumer Groups into the Details Drawer #492

Open
christiemolloy opened this issue May 10, 2021 · 13 comments
Open

Comments

@christiemolloy
Copy link
Contributor

christiemolloy commented May 10, 2021

This screenshot is from the user-testing URL. I believe we can replace these mock totals with actual data from the endpoint.

Screen Shot 2021-05-10 at 3 35 49 PM

This is a function Pete wrote to Fetch Instant Metrics. We should also link to the Topics page and the Consumer Groups page in the Data Plane.

  const fetchInstantMetrics = async () => {
    const accessToken = await authContext?.getToken();
    if (accessToken !== undefined && accessToken !== '') {
      try {
        const apisService = new DefaultApi({
          accessToken,
          basePath
        });
        if (!instanceDetail || !instanceDetail.id) {
          return;
        }
        await apisService.getMetricsByKafkaId(instanceDetail.id, 1, 5, ['kafka_controller_kafkacontroller_offline_partitions_count', 'kafka_controller_kafkacontroller_global_partition_count']).then((res) => {
          const data = res.data;
          let globalPartitionCounter = 0, offlinePartitionCounter = 0;
          data.items?.forEach(item => {
            const labels = item.metric;
            if (labels === undefined) {
              throw new Error('item.metric cannot be undefined');
            }
            if (item.values === undefined) {
              throw new Error('item.values cannot be undefined');
            }
            if (labels['__name__'] === 'kafka_controller_kafkacontroller_offline_partitions_count') {
              offlinePartitionCounter += item.values[item.values.length - 1].Value;
            }
            if (labels['__name__'] === 'kafka_controller_kafkacontroller_global_partition_count') {
              globalPartitionCounter += item.values[item.values.length - 1].Value;
            }
          });
          setGlobalPartitionCount(globalPartitionCounter);
          setOfflinePartitionCount(offlinePartitionCounter);
        });
      } catch (error) {
        let reason: string | undefined;
        if (isServiceApiError(error)) {
          reason = error.response?.data.reason;
        }
        /**
         * Todo: show user friendly message according to server code
         * and translation for specific language
         *
         */
        addAlert(t('something_went_wrong'), AlertVariant.danger, reason);
      }
    }
  };
@christiemolloy
Copy link
Contributor Author

@jgiardino anything else you want to add ?

@jgiardino
Copy link
Contributor

This is great! Probably just worth pointing out that these would display above the other metadata in the Details tab.

@ajaypratap003 ajaypratap003 self-assigned this May 11, 2021
@ajaypratap003
Copy link
Contributor

@pmuir Can you please confirm the above API function fetchInstantMetrics is correct to get the total Topic and Consumer.
Which one is the topic and consumer value in function.

@pmuir
Copy link
Contributor

pmuir commented May 11, 2021

I'm not sure this is the right way to do it anymore. Since I wrote that We added the instant and range queries. You should just be able to use the instant query directly. Also those metrics aren't the ones for topic count of consumer group count, they are for partitions.

@ajaypratap003
Copy link
Contributor

I'm not sure this is the right way to do it anymore. Since I wrote that We added the instant and range queries. You should just be able to use the instant query directly. Also those metrics aren't the ones for topic count of consumer group count, they are for partitions.

@pmuir Can you please give me some idea how can i get the total topic and consumers from API getMetricsByInstantQuery.
What I need to pass in filter and what I need to do for getting total count.

@pmuir
Copy link
Contributor

pmuir commented May 11, 2021

I'm not sure this is exposed at the moment. @redmikhail @redhatHameed do we have a list of metrics available published somewhere?

@redmikhail
Copy link

@pmuir
Copy link
Contributor

pmuir commented May 11, 2021

And I think @david-martin has a guide for how to request new metrics?

@redmikhail
Copy link

@david-martin
Copy link

And I think @david-martin has a guide for how to request new metrics?

https://github.com/bf2fc6cc711aee1a0c2a/observability-resources-mk/tree/main/resources/prometheus#prometheus-remote-write-to-observatorium

@redhatHameed
Copy link

@redmikhail
Copy link

Just as an additional step to the guide mentioned by @david-martin , please also update the document https://docs.google.com/spreadsheets/d/17hLZkcyD1_ujzB0uZQnmdQdDSLDgkmieXgN6Sx9i5Aw/edit#gid=56854475 until we have better all encompassing document

@christiemolloy
Copy link
Contributor Author

Spoke to David Martin about getting values for Topics / Consumer Groups and he gave me these formulas to use to calculate Topics / Consumer Groups:

Number of Topics:

count(kafka_topic_partitions{namespace="cmolloy-kafka-devexp-1sljc628mgipfw9vmttpar01hdw"})

{}	2

Number of partitions in each topic

sum(kafka_topic_partitions{namespace="cmolloy-kafka-devexp-1sljc628mgipfw9vmttpar01hdw"}) by(topic)

{topic="__consumer_offsets"}	50
{topic="__strimzi_canary"}	3

Number of consumer groups

count(count(kafka_consumergroup_current_offset{namespace="cmolloy-kafka-devexp-1sljc628mgipfw9vmttpar01hdw"}) by(consumergroup))

{}	1

I'll be giving these a try shortly.

@ajaypratap003 ajaypratap003 removed their assignment Jul 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants