You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,8 @@ To execute the request, enter it in the input field on the left and click on the
25
25
On the right side you will see the result of the query.
26
26
27
27
## GraphQL Voyager
28
-
You can view API Schema visualization in `/voyager` page in your browser. To see current production schema go to [here](https://api.beta.hawk.so/voyager)
28
+
You can view API Schema visualization in `/voyager` page in your browser.
29
+
To see current production schema go to [here](https://api.beta.hawk.so/voyager)
Histogram of MongoDB command duration by command, collection family, and database.
109
+
110
+
Labels:
111
+
-`command` - MongoDB command name (find, insert, update, etc.)
112
+
-`collection_family` - Collection family name (extracted from dynamic collection names to reduce cardinality)
113
+
-`db` - Database name
114
+
115
+
Buckets: 0.01, 0.05, 0.1, 0.5, 1, 5, 10 seconds
116
+
117
+
**Purpose**: Detect slow queries and high-latency collections.
118
+
119
+
**Note on Collection Families**: To reduce metric cardinality, dynamic collection names are grouped into families. For example:
120
+
-`events:projectId` → `events`
121
+
-`dailyEvents:projectId` → `dailyEvents`
122
+
-`repetitions:projectId` → `repetitions`
123
+
-`membership:userId` → `membership`
124
+
-`team:workspaceId` → `team`
125
+
126
+
This prevents metric explosion when dealing with thousands of projects, users, or workspaces, while still providing meaningful insights into collection performance patterns.
127
+
128
+
#### hawk_mongo_command_errors_total (Counter)
129
+
130
+
Counter of failed MongoDB commands grouped by command and error code.
131
+
132
+
Labels:
133
+
-`command` - MongoDB command name
134
+
-`error_code` - MongoDB error code
135
+
136
+
**Purpose**: Track transient or persistent database errors.
137
+
67
138
## Testing
68
139
69
140
### Manual Testing
@@ -98,11 +169,25 @@ The metrics implementation uses the `prom-client` library and consists of:
98
169
- Initializes a Prometheus registry
99
170
- Configures default Node.js metrics collection
100
171
- Defines custom HTTP metrics (duration histogram and request counter)
172
+
- Registers GraphQL and MongoDB metrics
101
173
- Provides middleware for tracking HTTP requests
102
174
- Creates a separate Express app for serving metrics
103
175
104
-
2.**Integration** (`src/index.ts`):
176
+
2.**GraphQL Metrics** (`src/metrics/graphql.ts`):
177
+
- Implements Apollo Server plugin for tracking GraphQL operations
178
+
- Tracks operation duration, errors, and resolver execution time
179
+
- Automatically captures operation name, type, and field information
180
+
181
+
3.**MongoDB Metrics** (`src/metrics/mongodb.ts`):
182
+
- Implements MongoDB command monitoring
183
+
- Tracks command duration and errors
184
+
- Uses MongoDB's command monitoring events
185
+
- Extracts collection families from dynamic collection names to reduce cardinality
0 commit comments