Skip to content

Commit

Permalink
feat: add new prometheus metrics endpoint #672 (#673)
Browse files Browse the repository at this point in the history
Adds endpoint `/metrics` for prometheus metrics collection to the Admin API Endpoint.

Closes #672
  • Loading branch information
drwatsno committed Aug 27, 2020
1 parent b41f3a0 commit 0f5c436
Show file tree
Hide file tree
Showing 21 changed files with 627 additions and 6 deletions.
18 changes: 18 additions & 0 deletions .schema/api.swagger.json
Expand Up @@ -320,6 +320,24 @@
}
}
},
"/metrics/prometheus": {
"get": {
"description": "```\nmetadata:\nannotations:\nprometheus.io/port: \"4445\"\nprometheus.io/path: \"/metrics/prometheus\"\n```",
"produces": [
"plain/text"
],
"tags": [
"admin"
],
"summary": "Get snapshot metrics from the Hydra service. If you're using k8s, you can then add annotations to\nyour deployment like so:",
"operationId": "prometheus",
"responses": {
"200": {
"description": "Empty responses are sent when, for example, resources are deleted. The HTTP status code for empty responses is\ntypically 201."
}
}
}
},
"/recovery/link": {
"post": {
"description": "This endpoint creates a recovery link which should be given to the user in order for them to recover\n(or activate) their account.",
Expand Down
4 changes: 4 additions & 0 deletions cmd/daemon/serve.go
Expand Up @@ -5,6 +5,8 @@ import (
"strings"
"sync"

"github.com/ory/kratos/metrics/prometheus"

"github.com/ory/analytics-go/v4"

"github.com/ory/x/flagx"
Expand Down Expand Up @@ -84,6 +86,7 @@ func serveAdmin(d driver.Driver, wg *sync.WaitGroup, cmd *cobra.Command, args []
r.RegisterAdminRoutes(router)
n.Use(NewNegroniLoggerMiddleware(l, "admin#"+c.SelfAdminURL().String()))
n.Use(sqa(cmd, d))
n.Use(d.Registry().PrometheusManager())

if tracer := d.Registry().Tracer(); tracer.IsLoaded() {
n.Use(tracer)
Expand Down Expand Up @@ -144,6 +147,7 @@ func sqa(cmd *cobra.Command, d driver.Driver) *metricsx.Service {
strings.ReplaceAll(verification.PublicVerificationInitPath, ":via", "email"),
verification.PublicVerificationRequestPath,
errorx.ErrorsPath,
prometheus.MetricsPrometheusPath,
},
BuildVersion: d.Registry().BuildVersion(),
BuildHash: d.Registry().BuildHash(),
Expand Down
3 changes: 3 additions & 0 deletions docs/docs/admin/managing-users-identities.mdx
Expand Up @@ -74,6 +74,7 @@ To create the account recovery link, use:
]}>
<TabItem value="curl">


```shell script
$ curl --request POST -sL \
--header "Content-Type: application/json" \
Expand All @@ -93,6 +94,7 @@ $ curl --request POST -sL \
</TabItem>
<TabItem value="go">


```go
package main

Expand Down Expand Up @@ -143,6 +145,7 @@ email, this feature is tracked as
</TabItem>
</Tabs>


### Import a User Identity

This feature is not implemented yet.
Expand Down

0 comments on commit 0f5c436

Please sign in to comment.