Skip to content

Export account resource metrics and configuration #322

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MattiasAng
Copy link

@MattiasAng MattiasAng commented Dec 10, 2024

Adds four new metrics that collects configured reserved memory and storage along with how many bytes are currently used of each.
This will allow users to monitor resource consumption based on set maximum.

I've decided to name the configured reserved metrics as max to align with configuration file rather than what the API response attribute is named (reserved).

Example response:

# HELP jetstream_account_max_memory JetStream Account Max Memory in bytes
# TYPE jetstream_account_max_memory gauge
jetstream_account_max_memory{account="test",account_id="test",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="test"} 1.048576e+07
# HELP jetstream_account_max_storage JetStream Account Max Storage in bytes
# TYPE jetstream_account_max_storage gauge
jetstream_account_max_storage{account="test",account_id="test",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="test"} 1.048576e+06
# HELP jetstream_account_memory_used Total number of bytes used by JetStream memory
# TYPE jetstream_account_memory_used gauge
jetstream_account_memory_used{account="test",account_id="test",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="test"} 0
# HELP jetstream_account_storage_used Total number of bytes used by JetStream storage
# TYPE jetstream_account_storage_used gauge
jetstream_account_storage_used{account="test",account_id="test",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="test"} 448245

Adds three new metrics that collects configured reserved memory and storage along with how many bytes are currently used.
@MattiasAng MattiasAng force-pushed the account-resource-metrics branch from e6f55c3 to 27340d1 Compare December 10, 2024 12:47
@mtmk mtmk self-assigned this Mar 25, 2025
@mtmk
Copy link
Member

mtmk commented Apr 2, 2025

works as expected in my local R1 setup:

jetstream_account_max_memory{account="A",account_id="A",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 5.12e+08
jetstream_account_max_memory{account="AC4",account_id="AC4",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 1.8446744073709552e+19
jetstream_account_max_memory{account="B",account_id="B",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 1.8446744073709552e+19
jetstream_account_max_storage{account="A",account_id="A",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 1e+09
jetstream_account_max_storage{account="AC4",account_id="AC4",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 1.8446744073709552e+19
jetstream_account_max_storage{account="B",account_id="B",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 1.8446744073709552e+19
jetstream_account_memory_used{account="A",account_id="A",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 0
jetstream_account_memory_used{account="AC4",account_id="AC4",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 0
jetstream_account_memory_used{account="B",account_id="B",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 0
jetstream_account_storage_used{account="A",account_id="A",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 237
jetstream_account_storage_used{account="AC4",account_id="AC4",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 0
jetstream_account_storage_used{account="B",account_id="B",cluster="",domain="",is_meta_leader="true",meta_leader="",server_id="http://localhost:8222",server_name="n1"} 0

@mtmk
Copy link
Member

mtmk commented Apr 2, 2025

we don't seem to have any tests around the account metrics. not sure @MattiasAng are you feeling generous enough to write a test case or perhaps we can leave that to another PR. wdyt @piotrpio?

@dg-plejd
Copy link

dg-plejd commented Apr 10, 2025

Hi! I was actually about to submit a PR for these metrics but then found this PR. :)

I adjusted my code so now my PR only includes an updated test matching the metrics names of this PR.

The test is in this PR #351 should work.

Sorry if this is not the correct way of doing this

@mtmk
Copy link
Member

mtmk commented Apr 10, 2025

Hi! I was actually about to submit a PR for these metrics but then found this PR. :)

I adjusted my code so now my PR only includes an updated test matching the metrics names of this PR.

The test is in this PR #351 should work.

Sorry if this is not the correct way of doing this

great! thanks @dg-plejd. more tests are always welcome. I'll have a look at the PR.

@MattiasAng
Copy link
Author

Thanks @dg-plejd, I was about to say that I'm a bit short on time.

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