You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/08/11 09:53:51 UTC

[GitHub] [nifi-minifi-cpp] lordgamez opened a new pull request, #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

lordgamez opened a new pull request, #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385

   https://issues.apache.org/jira/browse/MINIFICPP-1901
   
   ----------------------------------
   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   In order to streamline the review of the contribution we ask you
   to ensure the following steps have been taken:
   
   ### For all changes:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced
        in the commit message?
   
   - [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
   
   - [ ] Is your initial contribution a single, squashed commit?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] fgerlits commented on a diff in pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385#discussion_r959739177


##########
METRICS.md:
##########
@@ -46,77 +46,88 @@ To use the publisher a port should also be configured where the metrics will be
 
 	nifi.metrics.publisher.PrometheusMetricsPublisher.port=9936
 
-The last option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
+The following option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
 
 	# in minifi.properties
 
 	nifi.metrics.publisher.metrics=QueueMetrics,RepositoryMetrics,GetFileMetrics,DeviceInfoNode,FlowInformation
 
+An agent identifier should also be defined to identify which agent the metric is exposed from. If not set, the hostname is used as the identifier.
+
+	# in minifi.properties
+
+	nifi.metrics.publisher.agent.identifier=Agent1
+
 ## Metrics
 
 The following section defines the currently available metrics to be published by the MiNiFi C++ agent.
 
 NOTE: In Prometheus all metrics are extended with a `minifi_` prefix to mark the domain of the metric. For example the `connection_name` metric is published as `minifi_connection_name` in Prometheus.
 
+## Generic labels

Review Comment:
   this should either be one level lower (i.e., `###`), or without a section title
   
   as it is, it looks as if `QueueMetrics`, etc were sub-sections of `Generic labels`



##########
libminifi/src/utils/OsUtils.cpp:
##########
@@ -320,9 +316,11 @@ std::string OsUtils::getMachineArchitecture() {
   return "unknown";
 }
 
-}  // namespace utils
-}  // namespace minifi
-}  // namespace nifi
-}  // namespace apache
-}  // namespace org
+std::string OsUtils::getHostName() {
+  char hostname[1024];
+  hostname[1023] = '\0';
+  gethostname(hostname, 1023);
+  return {hostname};
+}

Review Comment:
   I don't know how often that happens, probably not very often, but if `gethostname()` returns an error (non-zero) status, then the return value will be a string containing garbage.  We should handle errors in a better way.



##########
extensions/prometheus/tests/PrometheusMetricsPublisherTest.cpp:
##########
@@ -98,11 +100,12 @@ TEST_CASE_METHOD(PrometheusPublisherTestFixtureWithDummyExposer, "Test adding me
     auto collection = stored_metric->Collect();
     for (const auto& metric_family : collection) {
       for (const auto& prometheus_metric : metric_family.metric) {
-        for (const auto& label : prometheus_metric.label) {
-          if (label.name == "metric_class") {
-            REQUIRE(ranges::find(valid_metrics_without_flow, label.value) != ranges::end(valid_metrics_without_flow));
-          }
-        }
+        auto metric_class_label_it = ranges::find_if(prometheus_metric.label, [](const auto& label) { return label.name == "metric_class"; });
+        REQUIRE(metric_class_label_it != ranges::end(prometheus_metric.label));
+        REQUIRE(ranges::find(valid_metrics_without_flow, metric_class_label_it->value) != ranges::end(valid_metrics_without_flow));

Review Comment:
   slightly shorter:
   ```suggestion
           REQUIRE(ranges::contains(valid_metrics_without_flow, metric_class_label_it->value));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm closed pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
szaszm closed pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385#discussion_r953021413


##########
METRICS.md:
##########
@@ -46,77 +46,88 @@ To use the publisher a port should also be configured where the metrics will be
 
 	nifi.metrics.publisher.PrometheusMetricsPublisher.port=9936
 
-The last option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
+The following option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
 
 	# in minifi.properties
 
 	nifi.metrics.publisher.metrics=QueueMetrics,RepositoryMetrics,GetFileMetrics,DeviceInfoNode,FlowInformation
 
+An agent identifier should also be defined to identify which agent the metric is exposed from. If not set the hostname is used as the identifier.

Review Comment:
   Updated in 04aa1120bda6a70d66461a87cddffc095c641499



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385#discussion_r960440940


##########
libminifi/src/utils/OsUtils.cpp:
##########
@@ -320,9 +316,11 @@ std::string OsUtils::getMachineArchitecture() {
   return "unknown";
 }
 
-}  // namespace utils
-}  // namespace minifi
-}  // namespace nifi
-}  // namespace apache
-}  // namespace org
+std::string OsUtils::getHostName() {
+  char hostname[1024];
+  hostname[1023] = '\0';
+  gethostname(hostname, 1023);
+  return {hostname};
+}

Review Comment:
   Updated in 0a19f946e806c662e17edf7ab4959aa5f66da3c2



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] lordgamez commented on a diff in pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385#discussion_r960440737


##########
METRICS.md:
##########
@@ -46,77 +46,88 @@ To use the publisher a port should also be configured where the metrics will be
 
 	nifi.metrics.publisher.PrometheusMetricsPublisher.port=9936
 
-The last option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
+The following option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
 
 	# in minifi.properties
 
 	nifi.metrics.publisher.metrics=QueueMetrics,RepositoryMetrics,GetFileMetrics,DeviceInfoNode,FlowInformation
 
+An agent identifier should also be defined to identify which agent the metric is exposed from. If not set, the hostname is used as the identifier.
+
+	# in minifi.properties
+
+	nifi.metrics.publisher.agent.identifier=Agent1
+
 ## Metrics
 
 The following section defines the currently available metrics to be published by the MiNiFi C++ agent.
 
 NOTE: In Prometheus all metrics are extended with a `minifi_` prefix to mark the domain of the metric. For example the `connection_name` metric is published as `minifi_connection_name` in Prometheus.
 
+## Generic labels

Review Comment:
   Updated in 0a19f946e806c662e17edf7ab4959aa5f66da3c2



##########
extensions/prometheus/tests/PrometheusMetricsPublisherTest.cpp:
##########
@@ -98,11 +100,12 @@ TEST_CASE_METHOD(PrometheusPublisherTestFixtureWithDummyExposer, "Test adding me
     auto collection = stored_metric->Collect();
     for (const auto& metric_family : collection) {
       for (const auto& prometheus_metric : metric_family.metric) {
-        for (const auto& label : prometheus_metric.label) {
-          if (label.name == "metric_class") {
-            REQUIRE(ranges::find(valid_metrics_without_flow, label.value) != ranges::end(valid_metrics_without_flow));
-          }
-        }
+        auto metric_class_label_it = ranges::find_if(prometheus_metric.label, [](const auto& label) { return label.name == "metric_class"; });
+        REQUIRE(metric_class_label_it != ranges::end(prometheus_metric.label));
+        REQUIRE(ranges::find(valid_metrics_without_flow, metric_class_label_it->value) != ranges::end(valid_metrics_without_flow));

Review Comment:
   Updated in 0a19f946e806c662e17edf7ab4959aa5f66da3c2



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi-minifi-cpp] szaszm commented on a diff in pull request #1385: MINIFICPP-1901 Add agent identity to Prometheus metrics

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1385:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1385#discussion_r943499085


##########
METRICS.md:
##########
@@ -46,77 +46,88 @@ To use the publisher a port should also be configured where the metrics will be
 
 	nifi.metrics.publisher.PrometheusMetricsPublisher.port=9936
 
-The last option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
+The following option defines which metric classes should be exposed through the metrics publisher in configured with a comma separated value:
 
 	# in minifi.properties
 
 	nifi.metrics.publisher.metrics=QueueMetrics,RepositoryMetrics,GetFileMetrics,DeviceInfoNode,FlowInformation
 
+An agent identifier should also be defined to identify which agent the metric is exposed from. If not set the hostname is used as the identifier.

Review Comment:
   I'm not great at english grammar, but I feel like a comma is missing from there.
   ```suggestion
   An agent identifier should also be defined to identify which agent the metric is exposed from. If not set, the hostname is used as the identifier.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org