Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31227 Address Prometheous histogram issues #18293

Conversation

rpastrana
Copy link
Member

@rpastrana rpastrana commented Feb 9, 2024

  • Fixes invalid quote on le=+Inf bucket
  • Qualifies sum and count w/ metric name
  • Normalizes all names to lowercase per promtool suggestion

Type of change:

  • This change is a bug fix (non-breaking change which fixes an issue).
  • This change is a new feature (non-breaking change which adds functionality).
  • This change improves the code (refactor or other change that does not change the functionality)
  • This change fixes warnings (the fix does not alter the functionality or the generated code)
  • This change is a breaking change (fix or feature that will cause existing behavior to change).
  • This change alters the query API (existing queries will have to be recompiled)

Checklist:

  • My code follows the code style of this project.
    • My code does not create any new warnings from compiler, build system, or lint.
  • The commit message is properly formatted and free of typos.
    • The commit message title makes sense in a changelog, by itself.
    • The commit is signed.
  • My change requires a change to the documentation.
    • I have updated the documentation accordingly, or...
    • I have created a JIRA ticket to update the documentation.
    • Any new interfaces or exported functions are appropriately commented.
  • I have read the CONTRIBUTORS document.
  • The change has been fully tested:
    • I have added tests to cover my changes.
    • All new and existing tests passed.
    • I have checked that this change does not introduce memory leaks.
    • I have used Valgrind or similar tools to check for potential issues.
  • I have given due consideration to all of the following potential concerns:
    • Scalability
    • Performance
    • Security
    • Thread-safety
    • Cloud-compatibility
    • Premature optimization
    • Existing deployed queries will not be broken
    • This change fixes the problem, not just the symptom
    • The target branch of this pull request is appropriate for such a change.
  • There are no similar instances of the same problem that should be addressed
    • I have addressed them here
    • I have raised JIRA issues to address them separately
  • This is a user interface / front-end modification
    • I have tested my changes in multiple modern browsers
    • The component(s) render as expected

Smoketest:

  • Send notifications about my Pull Request position in Smoketest queue.
  • Test my draft Pull Request.

Testing:

 - Fixes invalid quote on le=+Inf bucket
 - Qualifies sum and count w/ metric name
 - Normalizes all names to lowercase per promtool suggestion

Signed-off-by: Rodrigo Pastrana <[email protected]>
Copy link

github-actions bot commented Feb 9, 2024

@rpastrana
Copy link
Member Author

@ghalliday targeting latest point branch, but it seems this feature has been broken since its inception (#16624) which seems to have been included as far back as 8.12.x

@rpastrana rpastrana requested a review from kenrowland February 9, 2024 20:00
@@ -180,6 +180,9 @@ void PrometheusMetricSink::toPrometheusHistogram(const std::string &name, const
std::string PrometheusMetricSink::getPrometheusMetricName(const std::shared_ptr<IMetric> &pMetric)
{
std::string name = pMetric->queryName();
// Convert to lower case - per promtool output: "metric names should be written in 'snake_case' not 'camelCase'"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps out of scope of this issue, but lower casing all metric names per Prometheus promtool output:
dfs_8880_WsDfs_KeepAlive_seconds metric names should be written in 'snake_case' not 'camelCase'
dfs_8880_WsDfs_KeepAlive_seconds no help text

@@ -240,16 +243,16 @@ const std::vector<std::string> &PrometheusMetricSink::getHistogramLabels(const s

// Add the inf label
std::string infLabel(name);
infLabel.append("_bucket{\"le=+Inf\"}");
infLabel.append("_bucket{le=\"+Inf\"}");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect double quote location

labels.emplace_back(infLabel);

// Sum and count
std::string sumLabel;
sumLabel.append("_sum");
std::string sumLabel(name);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_sum and _count missing metric name prefix

@rpastrana
Copy link
Member Author

No more "INVALID" errors in prometheous ui:
image

Sample histogram metric accepted by prom chart ui:
image

std::string countLabel;
countLabel.append("_count");
std::string countLabel(name);
countLabel.append("_count{}");
Copy link
Contributor

@kenrowland kenrowland Feb 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why the '{}" is present. Braces are not part of what is shown on the Prometheus page documenting their exposition formats. See https://prometheus.io/docs/instrumenting/exposition_formats/

Please double check the reason for "{}" in both places where added

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great observation, it's legal syntax as confirmed by promtool and prometheous graph UI used as a label container. It's optional, and honestly it was added as I tested why your histograms were deemed invalid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What stands out to me is the fact there's currently no mechanism (at least not one I could see) to populate the histogram buckets w/ any available metadata as labels. That will likely need to be fixed.

@rpastrana rpastrana requested a review from kenrowland February 9, 2024 21:39
Copy link
Contributor

@kenrowland kenrowland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on comment that promtool accepted the {} appended to the histogram sum and count outputs.

@rpastrana
Copy link
Member Author

@ghalliday please merge. Currently targeting 9.4.x, but not sure if we should back port. This fixes a feature introduced in 8.12.x but to the best of my knowledge it never worked quite right for Prometheus

@ghalliday ghalliday merged commit 3a6806f into hpcc-systems:candidate-9.4.x Feb 15, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants