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

prometheus: Document new behavior of unavailable or unknown entities #34632

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

agoode
Copy link

@agoode agoode commented Sep 8, 2024

Proposed change

This documents the new prometheus behavior added in home-assistant/core#125492.

Type of change

  • Spelling, grammar or other readability improvements (current branch).
  • Adjusted missing or incorrect information in the current documentation (current branch).
  • Added documentation for a new integration I'm adding to Home Assistant (next branch).
  • Added documentation for a new feature I'm adding to Home Assistant (next branch).
  • Removed stale or deprecated documentation.

Additional information

Checklist

  • This PR uses the correct branch, based on one of the following:
    • I made a change to the existing documentation and used the current branch.
    • I made a change that is related to an upcoming version of Home Assistant and used the next branch.
  • The documentation follows the Home Assistant documentation standards.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration option, export_unavailable_metrics, allowing users to control metric exports during entity unavailability. The default value will change from true to false in early 2025.
  • Documentation

    • Updated documentation to clarify the behavior of metrics in unavailable or unknown states and provide examples for the new export_unavailable_metrics attribute, enhancing user understanding of its functionality.

@home-assistant home-assistant bot added has-parent This PR has a parent PR in a other repo next This PR goes into the next branch labels Sep 8, 2024
Copy link
Contributor

coderabbitai bot commented Sep 8, 2024

Warning

Rate limit exceeded

@agoode has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Files that changed from the base of the PR and between 9f884c4 and f29823c.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request modifies the Prometheus exporter behavior regarding the export of metrics for entities in unavailable or unknown states. A new configuration attribute, export_unavailable_metrics, is introduced to control whether metrics continue to be exported during these states. If set to true (default until early 2025), the last known value is exported; if set to false, metrics are unexported until the entity is available again. Documentation updates clarify these changes and include examples illustrating the different behaviors based on the configuration setting.

Changes

Files Change Summary
source/_integrations/prometheus.markdown Added export_unavailable_metrics boolean attribute to control metric export behavior during unavailability. Updated documentation with examples and noted upcoming default value change.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Sep 8, 2024

Deploy Preview for home-assistant-docs ready!

Name Link
🔨 Latest commit f29823c
🔍 Latest deploy log https://app.netlify.com/sites/home-assistant-docs/deploys/66f76f6ff6cad5000895a835
😎 Deploy Preview https://deploy-preview-34632--home-assistant-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
source/_integrations/prometheus.markdown (1)

Line range hint 202-222: Clarification on behavior during unavailable or unknown states.

The documentation provides a detailed explanation of how metrics are handled when entities are in unavailable or unknown states, depending on the export_unavailable_metrics setting. The use of examples and the explanation of the entity_available metric are particularly helpful.

However, there is a minor typographical error in line 202, where it states "are not be exported" which should be corrected to "are not exported". This will improve the clarity and professionalism of the documentation.

Please correct the typographical error:

- all non-excluded entities in an unavailable or unknown state are not be exported until they are available again.
+ all non-excluded entities in an unavailable or unknown state are not exported until they are available again.

source/_integrations/prometheus.markdown Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
source/_integrations/prometheus.markdown (1)

Line range hint 203-226: Excellent explanation of the attribute's behavior! Address the minor grammar suggestions.

The detailed explanation of how export_unavailable_metrics affects the behavior of metrics during unavailability is clear and comprehensive. It effectively covers both scenarios when the attribute is set to true or false.

The inclusion of the note indicating the upcoming change in the default value is also appreciated, as it keeps users informed about future changes.

Please address the following minor grammar suggestions:

  • Line 205: Add a comma after "unknown again" to improve readability.

    -If the entity goes into state unavailable or unknown again, two things can happen depending on the state of the `export_unavailable_metrics` configuration attribute.
    +If the entity goes into state unavailable or unknown again, two things can happen, depending on the state of the `export_unavailable_metrics` configuration attribute.
  • Line 226: Add a comma after "performant)" to separate the two independent clauses.

    -When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known. This makes it possible to write simpler (and more often performant) queries since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
    +When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known. This makes it possible to write simpler (and more often performant) queries, since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
Tools
LanguageTool

[uncategorized] ~205-~205: Possible missing comma found.
Context: ...ilable or unknown again, two things can happen depending on the state of the `export_u...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~215-~215: Possible missing comma found.
Context: ... entity is unavailable or in an unknown state thanks to a [recording rule](https://pr...

(AI_HYDRA_LEO_MISSING_COMMA)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 39de8ad and ca18f0f.

Files selected for processing (1)
  • source/_integrations/prometheus.markdown (4 hunks)
Additional context used
LanguageTool
source/_integrations/prometheus.markdown

[uncategorized] ~205-~205: Possible missing comma found.
Context: ...ilable or unknown again, two things can happen depending on the state of the `export_u...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~226-~226: Possible missing comma found.
Context: ...ite simpler (and more often performant) queries since there is no need to use `unless e...

(AI_HYDRA_LEO_MISSING_COMMA)

Additional comments not posted (3)
source/_integrations/prometheus.markdown (3)

72-76: ** Add a brief example to illustrate the attribute's usage.**

The past review comment suggesting the addition of a brief example is still applicable. Here's the suggested example to include:

# Example configuration.yaml entry
prometheus:
  export_unavailable_metrics: false

This example can help users quickly understand how to implement the attribute without needing to search elsewhere in the document.


138-138: LGTM!

The usage of export_unavailable_metrics: false in the advanced configuration example is correct and consistent with the attribute's documentation.


228-232: LGTM!

The example configuration setting export_unavailable_metrics: false is correct and consistent with the attribute's documentation.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ca18f0f and 1589cf5.

Files selected for processing (1)
  • source/_integrations/prometheus.markdown (4 hunks)
Additional context used
LanguageTool
source/_integrations/prometheus.markdown

[uncategorized] ~205-~205: Possible missing comma found.
Context: ...ilable or unknown again, two things can happen depending on the state of the `export_u...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~226-~226: Possible missing comma found.
Context: ...ite simpler (and more often performant) queries since there is no need to use `unless e...

(AI_HYDRA_LEO_MISSING_COMMA)

Additional comments not posted (4)
source/_integrations/prometheus.markdown (4)

72-76: Documentation for the new attribute is clear and comprehensive.

The documentation effectively explains the behavior of the export_unavailable_metrics attribute when set to true or false, and clearly states the default value.

As suggested in the previous review, consider adding a brief example to illustrate the attribute's usage in a configuration.yaml file. This can help users quickly understand how to implement it.

For example:

# Example configuration.yaml entry
prometheus:
  export_unavailable_metrics: false

138-138: The advanced configuration example correctly demonstrates setting export_unavailable_metrics to false.

The example aligns with the attribute's documentation and provides a practical demonstration of its usage.


203-209: The explanation provides important context and effectively introduces the export_unavailable_metrics attribute.

The documentation clearly explains the default behavior of metrics for unavailable or unknown entities and how the export_unavailable_metrics attribute impacts the export behavior.

The note about the upcoming change in the default value is crucial for users to be aware of and plan accordingly.

Tools
LanguageTool

[uncategorized] ~205-~205: Possible missing comma found.
Context: ...ilable or unknown again, two things can happen depending on the state of the `export_u...

(AI_HYDRA_LEO_MISSING_COMMA)


Line range hint 211-223: The explanation clearly describes the behavior when export_unavailable_metrics is set to true.

The documentation provides important information about the entity_available metric and its usage to indicate when an entity is unavailable or unknown.

The example of using a recording rule to filter out values is helpful for users to understand how to handle metrics for unavailable or unknown entities.

Tools
LanguageTool

[uncategorized] ~205-~205: Possible missing comma found.
Context: ...ilable or unknown again, two things can happen depending on the state of the `export_u...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~215-~215: Possible missing comma found.
Context: ... entity is unavailable or in an unknown state thanks to a [recording rule](https://pr...

(AI_HYDRA_LEO_MISSING_COMMA)

Comment on lines 224 to 216
### `export_unavailable_metrics: false`

When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known. This makes it possible to write simpler (and more often performant) queries since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.

```yaml
# Example configuration.yaml entry
prometheus:
export_unavailable_metrics: false
```

Copy link
Contributor

Choose a reason for hiding this comment

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

The explanation clearly describes the behavior and benefits when export_unavailable_metrics is set to false.

The documentation effectively highlights the advantages of using this setting, such as simpler queries and improved performance by automatically unexporting and re-exporting metrics based on entity availability.

The example configuration is helpful for users to understand how to set the attribute to false.

Consider adding the missing commas as indicated by the static analysis hints:

-When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known.
+When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known.

-This makes it possible to write simpler (and more often performant) queries since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
+This makes it possible to write simpler (and more often performant) queries, since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### `export_unavailable_metrics: false`
When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known. This makes it possible to write simpler (and more often performant) queries since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
```yaml
# Example configuration.yaml entry
prometheus:
export_unavailable_metrics: false
```
### `export_unavailable_metrics: false`
When `export_unavailable_metrics` is false, then metrics will automatically be unexported when unavailable or unknown, and return again automatically when available and known.
This makes it possible to write simpler (and more often performant) queries, since there is no need to use `unless entity_available == 0` or a recording rule to filter out these metrics.
```yaml
# Example configuration.yaml entry
prometheus:
export_unavailable_metrics: false
```
Tools
LanguageTool

[uncategorized] ~226-~226: Possible missing comma found.
Context: ...ite simpler (and more often performant) queries since there is no need to use `unless e...

(AI_HYDRA_LEO_MISSING_COMMA)

@agoode agoode changed the title prometheus: Document new config attribute export_unavailable_metrics prometheus: Document new behavior of unavailable or unknown entities Sep 28, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
source/_integrations/prometheus.markdown (1)

215-216: Remove extra blank line.

To comply with Markdown best practices and improve consistency, please remove one of the blank lines after the note's closing tag.

 {% endnote %}
 
-
🧰 Tools
🪛 Markdownlint

216-216: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e0a9945 and 41f75df.

📒 Files selected for processing (1)
  • source/_integrations/prometheus.markdown (1 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/prometheus.markdown

[style] ~201-~201: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...y when available and known. {% note %} Prior to Home Assistant 2024.10, this component ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[style] ~203-~203: Consider a shorter alternative to avoid wordiness.
Context: ...availablecorresponding metric to 0. In order to filter out these stale values,entity...

(IN_ORDER_TO_PREMIUM)

🪛 Markdownlint
source/_integrations/prometheus.markdown

216-216: Expected: 1; Actual: 2
Multiple consecutive blank lines

(MD012, no-multiple-blanks)

🔇 Additional comments (4)
source/_integrations/prometheus.markdown (4)

197-199: Clear explanation of the new behavior for unavailable or unknown entities.

The documentation accurately describes how the Prometheus exporter handles entities in unavailable or unknown states. This change improves the clarity and consistency of the exported metrics.


201-204: Clear explanation of the behavior change in Home Assistant 2024.10.

The note effectively communicates the important change in behavior for the Prometheus exporter. This information is crucial for users upgrading from earlier versions.

Minor style suggestion: Consider replacing "Prior to" with "Before" for slightly more concise wording, but this is not critical as the current phrasing is clear.

🧰 Tools
🪛 LanguageTool

[style] ~201-~201: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...y when available and known. {% note %} Prior to Home Assistant 2024.10, this component ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[style] ~203-~203: Consider a shorter alternative to avoid wordiness.
Context: ...availablecorresponding metric to 0. In order to filter out these stale values,entity...

(IN_ORDER_TO_PREMIUM)


204-211: Clear explanation of the old filtering method with a helpful example.

The documentation effectively explains the previous method of filtering out stale values using entity_available, including a practical YAML example. This context is valuable for users transitioning from the old behavior.

Minor suggestion: Consider replacing "In order to filter out" with "To filter out" for improved conciseness.


211-214: Clear explanation of the simplified querying and entity_available behavior.

The documentation effectively communicates that the old filtering method is no longer necessary and that queries can now be simpler. The information about entity_available metrics always being 1 is crucial for users to understand the new behavior.

Minor correction needed: Add a comma after "simpler" in the following sentence:

-This is no longer necessary, since all such metrics are now unexported, making it possible to write simpler (and more often performant) queries.
+This is no longer necessary, since all such metrics are now unexported, making it possible to write simpler, (and more often performant) queries.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
source/_integrations/prometheus.markdown (2)

201-204: Clear explanation of previous behavior with version-specific information.

This note effectively communicates the change in behavior, providing important context for users upgrading from older versions. The specific mention of Home Assistant 2024.10 is helpful for version tracking.

Consider a minor wording adjustment for improved clarity:

-Prior to Home Assistant 2024.10, this component would continue to export the latest known value when an entity would become unavailable or unknown and set the `entity_available` corresponding metric to 0.
+Prior to Home Assistant 2024.10, this component would continue to export the latest known value when an entity became unavailable or unknown, and set the corresponding `entity_available` metric to 0.
🧰 Tools
🪛 LanguageTool

[style] ~201-~201: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...y when available and known. {% note %} Prior to Home Assistant 2024.10, this component ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[style] ~203-~203: Consider a shorter alternative to avoid wordiness.
Context: ...availablecorresponding metric to 0. In order to filter out these stale values,entity...

(IN_ORDER_TO_PREMIUM)


211-213: Clear explanation of benefits from the new approach.

This segment effectively communicates that the previous workaround is no longer necessary and highlights the advantages of the new approach, including simpler and potentially more performant queries.

Consider a minor grammatical adjustment for improved clarity:

-This is no longer necessary, since all such metrics are now unexported, making it possible to write simpler (and more often performant) queries.
+This is no longer necessary, since all such metrics are now unexported, making it possible to write simpler (and often more performant) queries.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 41f75df and 9f884c4.

📒 Files selected for processing (1)
  • source/_integrations/prometheus.markdown (1 hunks)
🧰 Additional context used
🪛 LanguageTool
source/_integrations/prometheus.markdown

[style] ~201-~201: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...y when available and known. {% note %} Prior to Home Assistant 2024.10, this component ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[style] ~203-~203: Consider a shorter alternative to avoid wordiness.
Context: ...availablecorresponding metric to 0. In order to filter out these stale values,entity...

(IN_ORDER_TO_PREMIUM)

🔇 Additional comments (4)
source/_integrations/prometheus.markdown (4)

197-199: Excellent addition explaining the new behavior for unavailable or unknown entities.

This new explanation clearly describes how the Prometheus exporter handles entities in unavailable or unknown states, both at startup and during runtime. This information is crucial for users to understand the changes in behavior and aligns well with the PR objectives.


204-210: Helpful explanation of previous workaround with clear example.

This segment effectively explains the previous method for filtering out stale values using entity_available. The inclusion of a YAML example for a recording rule is particularly useful for users who might have been employing this approach. This context helps users understand the rationale behind the changes and how it simplifies their Prometheus queries.


213-215: Important clarification on entity_available metrics.

This concise statement clearly explains that all entity_available metrics are now always set to 1. This information is crucial for maintaining compatibility with existing queries and helps users understand how to interpret these metrics in the new system.


197-215: Excellent documentation update for the new Prometheus integration behavior.

This comprehensive update to the Prometheus integration documentation effectively communicates the new behavior regarding unavailable or unknown entities. The changes are well-structured, providing:

  1. Clear explanation of the new behavior
  2. Context about the previous behavior and its limitations
  3. Examples of how users might have worked around these limitations in the past
  4. Benefits of the new approach
  5. Important information for maintaining compatibility with existing setups

This level of detail and clarity will greatly assist users in understanding and adapting to the new behavior. Great job on providing such a thorough and user-friendly documentation update!

🧰 Tools
🪛 LanguageTool

[style] ~201-~201: ‘Prior to’ might be wordy. Consider a shorter alternative.
Context: ...y when available and known. {% note %} Prior to Home Assistant 2024.10, this component ...

(EN_WORDINESS_PREMIUM_PRIOR_TO)


[style] ~203-~203: Consider a shorter alternative to avoid wordiness.
Context: ...availablecorresponding metric to 0. In order to filter out these stale values,entity...

(IN_ORDER_TO_PREMIUM)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-parent This PR has a parent PR in a other repo next This PR goes into the next branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants