5 Commits

Author SHA1 Message Date
Vault Automation
7f0c0dbdad
Backport VAULT-43310: gcp kms counting of successful requests for billing into ce/main (#13947)
* no-op commit

* cherry pick

---------

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>
2026-04-17 11:03:05 -07:00
Vault Automation
d34cb72e68
Add counting for SSH certs and OTPs (#12368) (#12755)
* add cert counting for ssh

* add system view and fix errors

* add otp counting and change units for certs

* add storage tests

* fix census errors

* run make fmt

* use incrementer and change storage to match rfc

* run make fmt

* fix interface and remove parameter

* fix errors

* Update builtin/logical/ssh/path_creds_create.go



* remove error check

* add ssh counts to billing endpoint

* fix error

* add test case

* add ssh metric to test

* add get functions and tests

* fix format

* create function for ssh metrics

* refactoring and add test cases

* replace test check

* add ssh to billing overview test

---------

Co-authored-by: Rachel Culpepper <84159930+rculpepper@users.noreply.github.com>
Co-authored-by: Victor Rodriguez Rizo <vrizo@hashicorp.com>
2026-03-11 10:30:48 -04:00
Vault Automation
5f77aa78fc
VAULT-42759: Fix logic around setting updated_at field in billing endpoint, enhance tests coverage for the endpoint (#12454) (#12584)
* fix updated_at logic for previous month, add tests

* improvement: separate out metric names into consts

* wholistically cover all metrics in billing api test

* add actual totp data in the ent test

* fix more wording errors

* feedback: remove consts and use metric names directly

* fix a test

* simplify the logic around refreshing data

* simplify the logic by centralizing the atomic tracker interacting inside updateBillingMetrics method, fix the logic inside the endpoint, add tests

* miner fixes

* feedback: set time tracker to zero at set up and at start of month to indicate data has not been updated yet, update test

* attempt to fix deadlock by using statelock free version of update billing metrics method

* remove unnecessary locks inside request handling

* remove duplicate methods - instead create 2 wrappers around the method one with lock and one without

* add a new prefix and methods to store and retrieve last update time

* add comments to explain local prefix behavior for the update method

* replace atomic tracker with storage methods

* add method level tests for the update time storage methods

* add external tests to verify perf replicated cluster independelty track last update time now

* normalize time to utc before storing to storage, fix comments

* code scanql feedback: remove logging of raw error to prevent leakage

* feedback: reorganize and refactor update billing metric method wrappers

* feedback: add go doc to the get method

* feedback: retrieve stored update time for last month, instead of always putting end of month inside computeUpdatedTime

* use equal test instead of within duration inside util tests

* use require equal inside external tests too

* use end of the requested month inside the endpoint for past months

* update tests

* add a new test case for when time is not stored in storage

* fix a bug: add nil check before passing role counts and managed key counts to update method

* feedback: remove update call of of time inside setup billing

* Update vault/consumption_billing_util.go



* Update vault/logical_system_use_case_billing.go



* Update vault/logical_system_use_case_billing.go



* comment fix

* feedback: do not allow refresh on perf standby, add a warning and just retrieve stored data

* add tests

---------

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>
Co-authored-by: divyaac <divya.chandrasekaran@hashicorp.com>
2026-02-26 21:19:16 +00:00
Vault Automation
aa5bb66347
Backport KMSE HWM metrics CE fix into ce/main (#12481)
* KMSE HWM metrics: add missing function to oss file (#12475)

* [VAULT-41208] Add KMSE HWM Metrics (#12452)

* add kmse hwm key counts

* add kmse hwm key count census metrics

* add tests

* move storage functions to ent

* update billing endpoint tests

* add kmse to test billing response

* Apply suggestion from @aslamovamir

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>

---------

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>

---------

Co-authored-by: Jenny Deng <jenny.deng@hashicorp.com>
Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>
2026-02-23 14:49:09 -08:00
Vault Automation
c0e8de6ed9
VAULT-41572: hookup billing overview endpoint (#12328) (#12451)
* hookup the new path to the system backend

* add API client method for the new endpoint

* add test for the api method structure

* adjust the path implementation to capture all so-far added metrics

* add tests

* add go docs to the tests

* add more tests

* feedback: add go doc to test

* feedback: use require in tests

* fix the api: use parse secret method to properly parse response, add mapstructure definitions to api structs

* feedback: fix api method test by using mock api response

* Update vault/logical_system_use_case_billing.go



* Update vault/logical_system_use_case_billing.go



* feedback: refactor build month data method into methods that collect data separately

* feedback: make update_counts parameter a new user set field for the endpoint

* feedback: remove basic comments

* update logic around determining updated at field

* fix tests: add actual data and fix some assertions

* separate out ent only features from the neutral test file

* add a new test file to test ent only features

* call one update method to update all metrics

* add external tests for the endpoint

* add a changelog

* feedback: rename update_counts parameter to refresh_data

* feedback: fix determination of updated_at field

* feedback: convert created methods into core methods from system backend methods

* Update changelog/12328.txt



* feedback: create a new atomic tracker of last updated time for the metrics update and use that in the endpoint

* add unit tests to test updated_at

* always build metrics, even when the values are 0

* add test coverage to verify metrics still exist in the response with zero values even when there are no billing resources

* feedback: remove manual check of root namespace - rely on system backend to enforce root namespace restriction

* remove namespace test from oss test file

* properly accomodate new totp metric

* add pki cert and totp to endpoint response, add test coverage

* rename changelog file

* linters

* change changelog type to improvement, make the file CE and ENT

* test ent changelog

* fix some tests after the addition of totp and pki

* add test coverage for the new metrics in external and api tests

* make changelog CE file

---------

Co-authored-by: Amir Aslamov <amir.aslamov@hashicorp.com>
Co-authored-by: Violet Hynes <violet.hynes@hashicorp.com>
Co-authored-by: divyaac <divya.chandrasekaran@hashicorp.com>
2026-02-20 08:17:23 -05:00