prometheus-net.Contrib.MongoDb
0.5.5
See the version list below for details.
dotnet add package prometheus-net.Contrib.MongoDb --version 0.5.5
NuGet\Install-Package prometheus-net.Contrib.MongoDb -Version 0.5.5
<PackageReference Include="prometheus-net.Contrib.MongoDb" Version="0.5.5" />
paket add prometheus-net.Contrib.MongoDb --version 0.5.5
#r "nuget: prometheus-net.Contrib.MongoDb, 0.5.5"
// Install prometheus-net.Contrib.MongoDb as a Cake Addin #addin nuget:?package=prometheus-net.Contrib.MongoDb&version=0.5.5 // Install prometheus-net.Contrib.MongoDb as a Cake Tool #tool nuget:?package=prometheus-net.Contrib.MongoDb&version=0.5.5
prometheus-net.Contrib.MongoDb
Overview
prometheus-net.Contrib.MongoDb
is a C# library that provides client-side Prometheus instrumentation for MongoDB operations (instrumenting MongoDB C# Driver)
It captures various metrics related to MongoDB commands, errors, and performance, and exports them to Prometheus for monitoring and alerting.
The Why
Why create another metrics library for MongoDB when there's already mongodb_exporter?
It is true that mongodb_exporter
is a great tool for monitoring MongoDB, but it is a server-side tool that requires a separate process to run, possibly docker or other mode of deployment.
On top of that, it "actively" gathers information by polling MongoDB while this exporter will do it "passively" by instrumenting the MongoDB C# Driver, without the need to run a separate process.
Note: This library is still in development and more metrics will be added
Metrics Exposed
Command Duration (mongodb_client_command_duration
)
Histogram metric that measures the duration of MongoDB commands in seconds.
- Labels:
command_type
,status
,target_collection
,target_db
Open Cursors Count (mongodb_client_open_cursors_count
)
Gauge metric that tracks the number of open cursors.
- Labels:
target_collection
,target_db
Open Cursors Duration (mongodb_client_open_cursors_duration
)
Histogram metric that tracks the number of open cursors.
- Labels:
target_collection
,target_db
Open Cursor Document Count (mongodb_client_cursor_document_count
)
Summary metric that measures the document count fetched by a cursor.
- Labels:
target_collection
,target_db
Command Errors (mongodb_client_command_errors_total
)
Counter metric that counts the total number of MongoDB command errors.
- Labels:
command_type
,error_type
,target_collection
,target_db
Command Size (mongodb_command_response_size
)
Histogram metric that measures the size of MongoDB commands in bytes.
- Labels:
command_type
,target_collection
,target_db
Connection Creation Rate (mongodb_client_connection_creation_rate
)
Counter metric that captures the rate at which new MongoDB connections are created.
- Labels:
cluster_id
,end_point
Connection Duration (mongodb_client_connection_duration
)
Histogram metric that measures the time it takes to close a MongoDB connection, in seconds.
- Labels:
cluster_id
,end_point
Query Filter Size (mongodb_client_query_filter_size
)
Histogram metric that tracks the size of MongoDB query filters.
- Labels:
query_type
,target_collection
,target_db
Note: This metric tries to capture the complexity of the filters being used in MongoDB queries. It recursively counts the number of clauses and items in the filters, which could be a useful metric for understanding query performance. Note that the performance in this case also depends on any indexes or their lack in the collection.
Usage Example
Here's a simple example to instrument your MongoDB client:
using MongoDB.Driver;
var settings = MongoClientSettings.FromConnectionString("your_connection_string_here");
settings = settings.InstrumentForPrometheus();
var client = new MongoClient(settings);
Installation
This library is available as a NuGet package. To install, run:
Install-Package prometheus-net.Contrib.MongoDb
Contributing
If you'd like to contribute, please fork the repository and use a feature branch. Pull requests are warmly welcome.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- MongoDB.Driver (>= 2.19.0)
- prometheus-net (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.9 | 227 | 9/29/2023 |
3.0.2 | 136 | 9/28/2023 |
3.0.0 | 140 | 9/28/2023 |
2.0.6 | 140 | 9/28/2023 |
2.0.4 | 137 | 9/27/2023 |
2.0.2 | 140 | 9/27/2023 |
2.0.0 | 149 | 9/27/2023 |
1.0.0 | 143 | 9/27/2023 |
0.8.6 | 156 | 9/27/2023 |
0.8.4 | 128 | 9/27/2023 |
0.8.2 | 150 | 9/26/2023 |
0.8.0 | 111 | 9/26/2023 |
0.7.10 | 160 | 9/26/2023 |
0.7.8 | 127 | 9/26/2023 |
0.7.6 | 145 | 9/26/2023 |
0.7.4 | 131 | 9/26/2023 |
0.7.2 | 130 | 9/26/2023 |
0.7.0 | 126 | 9/26/2023 |
0.6.0 | 141 | 9/25/2023 |
0.5.5 | 143 | 9/25/2023 |
0.5.0 | 139 | 9/24/2023 |
0.3.1 | 135 | 9/23/2023 |
0.2.6 | 136 | 9/23/2023 |
Changes since version v0.3.1.0
:sparkles: New Features:
- [`dfc51c2`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/dfc51c2f815983d5e22191fe926722116915d30f) - add connection metrics provider *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`ac9368c`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/ac9368c00bbc38dc2ab91837d9714913003d221b) - query filter size metric (for those nasty queries with 2k IN clauses) *(commit by [@myarichuk](https://github.com/myarichuk))*
:white_check_mark: Tests:
- [`b53e246`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/b53e2463b30421056ac04ac4747fd6b2d42518b9) - add tests for that, of course *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`741fa6b`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/741fa6b1703451748c48c4b617acca6c2ce5302d) - add tests for query filter size metric *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`3984864`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/398486417b8cb88df40acbf8491c9b90331ebd8e) - introduce MongoTestContext that would abstract away repeated code for setup and tearing down test MongoDb instances *(commit by [@myarichuk](https://github.com/myarichuk))*
:wrench: Chores:
- [`883aaea`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/883aaeaaf335c3b03bb25911c488be30fafff62b) - fix typos and add new metrics to readme *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`50e56d6`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/50e56d669c074ac1910de1804e9b34c210d8c542) - remove unnecessary code (code quality) *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`62273ae`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/62273aee6ca68d449477c97bd792a40925efbcc2) - minor rename *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`81adff4`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/81adff4bd2122d9bbaca9c2f0744fa7bfc194167) - minor fixes (make sure RegisterAll() for metric provider happens only once ever) *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`240882e`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/240882e32cab2060cdcf550a1adff83117860c07) - adjust readme file for the new metric *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`ed0e68b`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/ed0e68ba50f6069eb2338bef8c53a35fccb26200) - try to enhance ConnectionMetricsTests (not sure why it fails on Linux) *(commit by [@myarichuk](https://github.com/myarichuk))*
- [`f8c9d09`](https://github.com/myarichuk/prometheus-net.Contrib.MongoDb/commit/f8c9d0910f5753ad4178cb14f37dcf80235b908e) - add some debugging code to tests *(commit by [@myarichuk](https://github.com/myarichuk))*