Skip to content

Commit 2e2915c

Browse files
1 parent 87aa5e0 commit 2e2915c

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

docs/contrib/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Repository for third party middlewares with dependencies.
2929
* [JWT](./jwt/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+jwt%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-jwt.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3030
* [Loadshed](./loadshed/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+loadshed%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-loadshed.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3131
* [NewRelic](./fibernewrelic/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+fibernewrelic%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-fibernewrelic.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
32+
* [Monitor](./monitor/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+Monitor%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-monitor.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3233
* [Open Policy Agent](./opafiber/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+opafiber%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-opafiber.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3334
* [Otelfiber (OpenTelemetry)](./otelfiber/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+otelfiber%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-otelfiber.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>
3435
* [Paseto](./paseto/README.md) <a href="https://github.com/gofiber/contrib/actions?query=workflow%3A%22Test+paseto%22"> <img src="https://img.shields.io/github/actions/workflow/status/gofiber/contrib/test-paseto.yml?branch=main&label=%F0%9F%A7%AA%20&style=flat&color=75C46B" /> </a>

docs/contrib/monitor/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
---
2+
id: monitor
3+
---
4+
5+
# Monitor
6+
7+
![Release](https://img.shields.io/github/v/tag/gofiber/contrib?filter=monitor*)
8+
![Discord](https://img.shields.io/discord/704680098577514527?style=flat&label=%F0%9F%92%AC%20discord&color=00ACD7)
9+
![Test](https://github.com/gofiber/contrib/workflows/Tests/badge.svg)
10+
![Security](https://github.com/gofiber/contrib/workflows/Security/badge.svg)
11+
![Linter](https://github.com/gofiber/contrib/workflows/Linter/badge.svg)
12+
13+
Monitor middleware for [Fiber](https://github.com/gofiber/fiber) that reports server metrics, inspired by [express-status-monitor](https://github.com/RafalWilinski/express-status-monitor)
14+
15+
![](https://i.imgur.com/nHAtBpJ.gif)
16+
17+
## Install
18+
19+
This middleware supports Fiber v3.
20+
21+
```
22+
go get -u github.com/gofiber/fiber/v3
23+
go get -u github.com/gofiber/contrib/monitor
24+
```
25+
26+
### Signature
27+
28+
```go
29+
monitor.New(config ...monitor.Config) fiber.Handler
30+
```
31+
32+
### Config
33+
34+
| Property | Type | Description | Default |
35+
| :--------- | :------------------------ | :----------------------------------------------------------------------------------- | :-------------------------------------------------------------------------- |
36+
| Title | `string` | Metrics page title. | `Fiber Monitor` |
37+
| Refresh | `time.Duration` | Refresh period. | `3 seconds` |
38+
| APIOnly | `bool` | Whether the service should expose only the montioring API. | `false` |
39+
| Next | `func(c *fiber.Ctx) bool` | Define a function to add custom fields. | `nil` |
40+
| CustomHead | `string` | Custom HTML code to Head Section(Before End). | `empty` |
41+
| FontURL | `string` | FontURL for specilt font resource path or URL. also you can use relative path. | `https://fonts.googleapis.com/css2?family=Roboto:wght@400;900&display=swap` |
42+
| ChartJsURL | `string` | ChartJsURL for specilt chartjs library, path or URL, also you can use relative path. | `https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.bundle.min.js` |
43+
44+
### Example
45+
46+
```go
47+
package main
48+
49+
import (
50+
"log"
51+
52+
"github.com/gofiber/fiber/v3"
53+
"github.com/gofiber/contrib/monitor"
54+
)
55+
56+
func main() {
57+
app := fiber.New()
58+
59+
// Initialize default config (Assign the middleware to /metrics)
60+
app.Get("/metrics", monitor.New())
61+
62+
// Or extend your config for customization
63+
// Assign the middleware to /metrics
64+
// and change the Title to `MyService Metrics Page`
65+
app.Get("/metrics", monitor.New(monitor.Config{Title: "MyService Metrics Page"}))
66+
67+
log.Fatal(app.Listen(":3000"))
68+
}
69+
```
70+
71+
72+
## Default Config
73+
74+
```go
75+
var ConfigDefault = Config{
76+
Title: defaultTitle,
77+
Refresh: defaultRefresh,
78+
FontURL: defaultFontURL,
79+
ChartJsURL: defaultChartJSURL,
80+
CustomHead: defaultCustomHead,
81+
APIOnly: false,
82+
Next: nil,
83+
}
84+
```

0 commit comments

Comments
 (0)