Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Windows Tipps & SecurityDave Plummer Has Made the Task Manager of Your Dreams(21.09.2026 um 21:20 Uhr)
Sichere ProgrammierungSubqueries and CTEs: Asking a Question Inside a Question(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungTVL Trend Analysis & Liquidity Risk Assessment: Lido(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungReact is Officially Dead in 2026 (Thanks to AI)(21.09.2026 um 21:01 Uhr)
Sichere ProgrammierungUsing SHA256 to Build Trustworthy Data Portals in Brazil(21.09.2026 um 21:01 Uhr)
Sichere Programmierung🚀 I reached 1,001 views on DEV!(21.09.2026 um 21:03 Uhr)
Sichere ProgrammierungReact Mental Models 2(21.09.2026 um 21:05 Uhr)
Sichere ProgrammierungAustralian RAM and SSD prices climb as stock tightens(21.09.2026 um 21:09 Uhr)
Windows Tipps & SecurityDave Plummer Has Made the Task Manager of Your Dreams(21.09.2026 um 21:20 Uhr)
Sichere ProgrammierungSubqueries and CTEs: Asking a Question Inside a Question(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungTVL Trend Analysis & Liquidity Risk Assessment: Lido(21.09.2026 um 21:00 Uhr)
Sichere ProgrammierungReact is Officially Dead in 2026 (Thanks to AI)(21.09.2026 um 21:01 Uhr)
Sichere ProgrammierungUsing SHA256 to Build Trustworthy Data Portals in Brazil(21.09.2026 um 21:01 Uhr)
Sichere Programmierung🚀 I reached 1,001 views on DEV!(21.09.2026 um 21:03 Uhr)
Sichere ProgrammierungReact Mental Models 2(21.09.2026 um 21:05 Uhr)
Sichere ProgrammierungAustralian RAM and SSD prices climb as stock tightens(21.09.2026 um 21:09 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

Part 2: Setup Dashboard with grafana and nestjs

With the help of this blog,where we'll walk you through using Grafana to create a dynamic dashboard and NestJS to export data with ease. In just a few easy steps, up your data visualisation game and simplify backend development. Are you…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

With the help of this blog,where we'll walk you through using Grafana to create a dynamic dashboard and NestJS to export data with ease. In just a few easy steps, up your data visualisation game and simplify backend development. Are you ready to turn unstructured data into meaningful dashboards? Let's get started! 🚀🏊



Part One:

In the initial phase, we'll configure Prometheus with our Nest app. This ensures that the app can export data via specific endpoints. Prometheus will then scrape this data and seamlessly export it to Grafana.



1/

we need to install willsoto:

yarn add @willsoto/nestjs-prometheus prom-client

or

npm install @willsoto/nestjs-prometheus prom-client



2/

In the app module imports, be sure to include the following:



PrometheusModule.register({

path: '/app-metrics',

}),



this specifies the endpoint where the Prometheus metrics will be exposed.



Similarly, in the AppModule providers, make sure to include:




 makeCounterProvider({
name: 'count',
help: 'metric_help',
labelNames: ['method', 'origin'] as string[],
}),
makeGaugeProvider({
name: 'gauge',
help: 'metric_help',
}),






FEEL FREE TO CUSTOMIZE THEM ACCORDING TO YOUR PREFERENCES.

makeCounterProvider is likely a function or method provided by the @willsoto/nestjs-prometheus library to create a Prometheus Counter metric




  • name: Specifies the name of the metric. In this case, it's set to "count"


  • help: Provides a description or help text for the metric.


  • labelNames: Specifies label names for the metric. Labels are key-value pairs that allow you to differentiate between different dimensions of the metric. In this case, labels for 'method' and 'origin' are defined.




3/

In order to capture all requests, we must add intercepts to our root application




export class AppModule {
configure(consumer: MiddlewareConsumer) {
//forRoutes('yourRootapi')
consumer.apply(MetricsMiddleware).forRoutes('/api');
}
}






We must include something similar to this in our interceptors:

two essential steps are necessary. First, define our metrics, and second, explore them to export significant data




@Injectable()
export class CustomMetricsMiddleware implements NestMiddleware {

public customDurationGauge: Gauge<string>;
public customErrorsCounter: Counter<string>;

constructor(
// Must be identical to those declared in our AppModule
@InjectMetric('count') public appCounter: Counter<string>,
@InjectMetric('gauge') public appGauge: Gauge<string>,
)
{
// Customizing the names and help messages for metrics
this.customDurationGauge = new Gauge<string>({
name: 'app_duration_metrics',
help: 'app_concurrent_metrics_help',
labelNames: ['app_method', 'app_origin', 'le'],
});
this.customErrorsCounter = new Counter<string>({
name: 'app_error_metrics',
help: 'app_usage_metrics_to_detect_errors',
labelNames: ['app_method', 'app_origin', 'app_status'],
});
}






In this example, I utilize counter metrics to count the number of requests based on method and origin, and gauge metrics to calculate the duration of each request.




 use(req: Request, res: Response, next: NextFunction) {
// Incrementing custom counter and gauge
this.appCounter.labels(req.method, req.originalUrl).inc();
this.appGauge.inc();

// Recording start time for measuring duration
const startTime = Date.now();

// Setting up a callback for when the response finishes
res.on('finish', () => {
// Calculating the duration and recording it in the custom duration gauge
const endTime = Date.now();
const duration = endTime - startTime;
this.customDurationGauge
.labels(req.method, req.originalUrl, (duration / 1000).toString())
.set(duration);

// Incrementing the custom errors counter based on the response status code
this.customErrorsCounter.labels(req.method, req.originalUrl, res.statusCode.toString()).inc();
});

// Continuing with the middleware chain
next();
}






Part Two:

In the next section, we'll shift our focus to Grafana aiming to consume metrics and visually them in a meaningful way:




  • So the initial step is to log in using admin/admin for the first sign-in and configure the data source like the example below :



Login



data source



Image description



Image description



Now, we will begin with our dashboard:



visit Grafana dashboards and search for "Node Exporter Full"



Image description



and copy the ID:



Image description



Image description



Image description



Image description



Image description



You need to choose a datasource that matches the name you used before:



Image description



and BOOM NOW WE HAVE A DASHBOARD :



Image description



YOU CAN CUSTOMIZE YOUR DASHBOARD AS YOU WANT FOR EXAMPLE FOR THE COUNTER THAT WE EXPORT FROM OUR NESTJS APP WE CAN VISUALIZE IT THERE LIKE THIS WAY :



Image description



Image description



And here we can say that we have reached the end of our blog. I hope you find it useful and informative.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Part 2: Setup Dashboard with grafana and nestjs

Thematisch verwandte Begriffe: Part, Setup, Dashboard, with · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-77582 | Tinyauth is an authentication and authorization server. Prior to 5.1.0, …
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick