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

Generate metrics reference docs #2164

Merged
merged 16 commits into from
Mar 1, 2024
Merged

Generate metrics reference docs #2164

merged 16 commits into from
Mar 1, 2024

Conversation

lambdanis
Copy link
Contributor

@lambdanis lambdanis commented Feb 28, 2024

Add a metrics reference documentation page, autogenerated with github.com/isovalent/metricstool.

Fixes #1856

@lambdanis lambdanis added area/documentation Improvements or additions to documentation release-note/docs This PR updates the documentation. labels Feb 28, 2024
Copy link
Contributor

@willfindlay willfindlay left a comment

Choose a reason for hiding this comment

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

This looks AMAZING 🎉

Makefile Show resolved Hide resolved
@mtardy
Copy link
Member

mtardy commented Feb 29, 2024

Where's the Netlify preview link when we need it?

Preview here.

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

Thanks, that will be a very useful addition to the doc!! Sorry I reviewed that one first but I wanted to highlight some things on the output of the autogenerated page.

"events": "Tetragon Events",
}

overrides := []metricsmd.LabelOverrides{
Copy link
Member

Choose a reason for hiding this comment

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

do you need to provide "false" values here or can you just pass an empty object? Can be a bit misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could pass empty strings as label values, then the docs would still list the label names but not values.

I'm thinking having example values is helpful (users can see the format), but currently the reference doesn't distinguish between example and real values, so I see how it can be misleading. Maybe the next iteration of metricstool could support rendering example and real label values differently or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the build info labels specifically, we can make them less confusing by updating them on a release too.

docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

I made some comments on the output of your tool, I see two ways of tweaking stuff:

  • maybe you want your output to be consistent with a previous behavior and then we need some sed commands to modify the output as I do with gRPC and Helm (because I don't control the tool).
  • you can simply modify your tool output directly.

lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This will allow to drop the "autogenerated" comment when rendering the metrics
reference as a Hugo docs page.

Requested here:
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This is useful when the metrics reference is embedded in another markdown
document.

Requested here:
cilium/tetragon#2164 (comment)
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This will allow to drop the "autogenerated" comment when rendering the metrics
reference as a Hugo docs page.

Requested here:
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This is useful when the metrics reference is embedded in another markdown
document.

Requested here:
cilium/tetragon#2164 (comment)
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This is useful when the metrics reference is embedded in another markdown
document.

Requested here:
cilium/tetragon#2164 (comment)
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
@lambdanis lambdanis force-pushed the pr/lambdanis/metricsmd branch 2 times, most recently from e9566d8 to f775376 Compare March 1, 2024 01:30
lambdanis added a commit to isovalent/metricstool that referenced this pull request Mar 1, 2024
This is useful when the metrics reference is embedded in another markdown
document.

Requested here:
cilium/tetragon#2164 (comment)
cilium/tetragon#2164 (comment)

Signed-off-by: Anna Kapuscinska <[email protected]>
@lambdanis lambdanis force-pushed the pr/lambdanis/metrics-init-labels branch from cebc21f to b24e3f1 Compare March 1, 2024 12:47
@lambdanis lambdanis force-pushed the pr/lambdanis/metricsmd branch 2 times, most recently from 52ced09 to 0004b79 Compare March 1, 2024 16:14
Base automatically changed from pr/lambdanis/metrics-init-labels to main March 1, 2024 16:32
This command utilizes github.com/isovalent/metricstool/pkg/metricsmd to
generate a metrics reference.

Signed-off-by: Anna Kapuscinska <[email protected]>
`make metrics-docs` generates metrics reference documentation page using
`tetra metrics-docs` command.

Signed-off-by: Anna Kapuscinska <[email protected]>
Split InitMetrics function into multiple functions to divide metrics into
logical groups. Introduce InitMetricsForDocs function used in `tetra
metrics-docs` command.

There are no functional changes in this commit. This refactoring is
a preparation for further improvements in the generated metrics docs.

Signed-off-by: Anna Kapuscinska <[email protected]>
Copy link

netlify bot commented Mar 1, 2024

Deploy Preview for tetragon ready!

Name Link
🔨 Latest commit b509234
🔍 Latest deploy log https://app.netlify.com/sites/tetragon/deploys/65e212292146b100086a212f
😎 Deploy Preview https://deploy-preview-2164--tetragon.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.

Update metrics-docs tetra command and Makefile rule to split metrics reference
into three sections: health metrics, resources metrics and events metrics.

Signed-off-by: Anna Kapuscinska <[email protected]>
Initialize tetragon_events_total with all possible event types and example
process metadata.

Initialize tetragon_policy_events_total with example policy and kprobe.

Signed-off-by: Anna Kapuscinska <[email protected]>
Initialize tetragon_generic_kprobe_merge_errors_total with all possible error
types and example kprobes.

Signed-off-by: Anna Kapuscinska <[email protected]>
Initialize tetragon_syscalls_total with example syscall and process metadata.

Signed-off-by: Anna Kapuscinska <[email protected]>
observer.bpfCollector doesn't report any metrics if Tetragon isn't fully
initialized - so also when we generate metrics docs with tetra. To include
observer BPF metrics in metrics docs, let's define a "fake" collector -
observer.bpfZeroCollector - reporting same metrics as observer.bpfCollector
but with hardcoded zero values.

Signed-off-by: Anna Kapuscinska <[email protected]>
eventmetrics.bpfCollector doesn't report any metrics if Tetragon isn't fully
initialized - so also when we generate metrics docs with tetra. To include
BPF event metrics in metrics docs, let's define a "fake" collector -
eventmetrics.bpfZeroCollector - reporting same metrics as eventmetrics.bpfCollector
but with hardcoded zero values.

Signed-off-by: Anna Kapuscinska <[email protected]>
policyStateCollector doesn't report any metrics if Tetragon isn't fully
initialized - so also when we generate metrics docs with tetra. To include
policy state metrics in metrics docs, let's define a "fake" collector -
policyStateZeroCollector - reporting same metrics as policyStateZeroCollector
but with hardcoded zero values.

Signed-off-by: Anna Kapuscinska <[email protected]>
Signed-off-by: Anna Kapuscinska <[email protected]>
Use a Hugo shortcode so that the comment isn't rendered into the final HTML.

Signed-off-by: Anna Kapuscinska <[email protected]>
@lambdanis
Copy link
Contributor Author

Ok, after a few rebases this should be good now.

Here is the final docs preview: https://deploy-preview-2164--tetragon.netlify.app/docs/reference/metrics/
@mtardy Please take another look if you want.

Copy link
Member

@mtardy mtardy left a comment

Choose a reason for hiding this comment

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

I think it looks good now and will be very useful, thanks a lot!

docs/content/en/docs/reference/metrics.md Outdated Show resolved Hide resolved
Comment on lines +19 to +22
| `commit` | `931b70f2c9878ba985ba6b589827bea17da6ec33` |
| `go_version` | `go1.22.0` |
| `modified` | `false` |
| `time ` | `2022-05-13T15:54:45Z` |
Copy link
Member

Choose a reason for hiding this comment

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

I like that it's referencing the OSS commit 😻

It looks a bit odd as it's not rendered as a link, especially in the TOC.

Signed-off-by: Anna Kapuscinska <[email protected]>
@lambdanis lambdanis merged commit 9111a3a into main Mar 1, 2024
39 checks passed
@lambdanis lambdanis deleted the pr/lambdanis/metricsmd branch March 1, 2024 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation Improvements or additions to documentation release-note/docs This PR updates the documentation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: Add a metrics reference
3 participants