Bitwarden_rs: Prometheus metrics

Created on 31 May 2019  路  8Comments  路  Source: dani-garcia/bitwarden_rs

Hi,

If I was gonna implement metrics importing using https://github.com/sd2k/rocket_prometheus or https://github.com/pingcap/rust-prometheus would such an addition be welcome to the project;

  1. Behind a feature flag, or
  2. In general build in, but enabled by an environmental variable, or
  3. Always enabled, or
  4. Not at all

All 8 comments

Personally I'd love to see Prometheus metrics being available behind environment variable. (or generally as any other setting we have) Even better if there was some option to enable authorization.

Personally any addition is welcome as long as it's easy to enable/disable and doesn't complicate the code a ton or impact performance.

About how to activate the feature, the best way is hiding it behind an environment variable. The only exceptions I can think of are when:

  • the new features add external dependencies and link to system binaries
  • it's impossible to switch the feature on and off at runtime

Sadly both exceptions apply to adding new database support but I can't imagine they would for this case.

Out of curiosity, what kind of metrics are you interested in collecting?

Okay that sounds good, I'm thinking I'll add 4 environmental variables then, something like:

METRICS_ENABLE
METRICS_USERNAME
METRICS_PASSWORD
METRICS_URI

Where's enable will be the feature toggle with a default to false, username and password will be optional, and if provided will ask for http basic auth before providing metrics and finally metrics uri will be the suburl where metrics are served, defaulting to /metrics

The metrics I'm planning to expose are general http request cycle stuff, numbers of syncs potentially labeled by uuid and database metrics such as the total number of ciphers, ciphers by organization and user, etc.

I'm very open for input on specific metrics you'd like to see included too though.

I would like to see failed logins, so I can set an alarm on that event in Grafana!

And maybe:

  • Nr of ogranizations
  • Nr of users
  • Nr of folders
  • Nr of entries
  • Nr of collections
  • Nr of attachments
  • Nr of lookups for username/password

Hi @MarsWarrior, I already have the database metrics set up. Including number of users per organization, and such, some of which may have to go behind an environmental variable or be toggleable for people with larger userbases, if they want to avoid too many metrics.

  • For instance the number of ciphers per user, which can produce a lot of metrics on a busy server.

Number of lookups will be hard, as you cannot see when a user makes a lookup after synchronizing. - You can however potentially track synchronizations.

I would like to see failed logins, so I can set an alarm on that event in Grafana!

I'd love to see that one as well!

I'm going to close this @Skeen now. If you have more questions, maybe hop onto the chat. We can also discuss under WIP PR once you get there as that's probably more appropriate place to discuss these things.

@mprasil that's fair, let's discuss the PR once it's ready and submitted.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gregor-Agnes picture Gregor-Agnes  路  6Comments

Jungack picture Jungack  路  3Comments

jjlin picture jjlin  路  5Comments

mikkelnl picture mikkelnl  路  3Comments

newkind picture newkind  路  4Comments