Prometheus connection with the backend
pedro-gattai
HOBBYOP

10 months ago

I have two services, one for my backend and another for Prometheus. How can I make Prometheus scrape my backend? I am using Nest.js for my backend. If you need additional information, I can share it.

Solved

16 Replies

pedro-gattai
HOBBYOP

10 months ago

5075a609-a7b3-4ef7-abed-b5520d932087


brody
EMPLOYEE

10 months ago

hello, you would want to use the prom client in your codebase


pedro-gattai
HOBBYOP

10 months ago

My problem is i cant conect with backend. i have to use prom client?

1356355785021723000


brody
EMPLOYEE

10 months ago

are those the correct ports that your application is listening on?


pedro-gattai
HOBBYOP

10 months ago

yes, i just need to connect to backend service the first link


pedro-gattai
HOBBYOP

10 months ago

Maybe it's because it's an HTTP connection and not an HTTPS connection?


brody
EMPLOYEE

10 months ago

it needs to be http, so you have that correct.

the pricate network is ipv6 only, so are you listening on ipv6?


pedro-gattai
HOBBYOP

10 months ago

Yes ipv6, the error are in the port

1356358812084474000


pedro-gattai
HOBBYOP

10 months ago

this is my main.ts:

import { NestFactory } from '@nestjs/core'
import { AppModule } from './app.module'
import * as cookieParser from 'cookie-parser'
import * as dotenv from 'dotenv'
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'
import { ValidationPipe } from '@nestjs/common'
import { AxiosInterceptor } from './axios.interceptor'
import { MetricsService } from './modules/metrics/metrics.service'
import { MetricsInterceptor } from './modules/metrics/metrics.interceptor'

dotenv.config()

async function bootstrap() {
const app = await NestFactory.create(AppModule)
const port = process.env.PORT || 3000
const isDevelopment = process.env.NODE_ENV !== 'PROD'

// Metrics setup
const metricsService = app.get(MetricsService)
app.useGlobalInterceptors(new MetricsInterceptor(metricsService))

app.useGlobalPipes(new ValidationPipe())
app.use(cookieParser())
app.useGlobalInterceptors(new AxiosInterceptor())

app.useGlobalPipes(new ValidationPipe())
app.use(cookieParser())

app.enableCors({
origin: [
links - i have the correct links here
],
credentials: true,
})

if (isDevelopment) {
const config = new DocumentBuilder()
.setTitle('VAULT | Wallet - SaaS API')
.setDescription('The documentation of all Wallet - SaaS API Project')
.setVersion('1.0')
.build()
const document = SwaggerModule.createDocument(app, config)
SwaggerModule.setup('api', app, document)
}

await app.listen(port, '::')
console.log(Server is listening on all interfaces (:::${port}))
}

bootstrap()

My question is: when I deploy, does the port my backend is listening on change every time?


brody
EMPLOYEE

10 months ago

no it doesn't


brody
EMPLOYEE

10 months ago

have you tried using the correct port?


pedro-gattai
HOBBYOP

10 months ago

have worked


pedro-gattai
HOBBYOP

10 months ago

with the port 8080


pedro-gattai
HOBBYOP

10 months ago

nice, tnks


brody
EMPLOYEE

10 months ago

awesome!


brody
EMPLOYEE

10 months ago

!s


Status changed to Solved brody 10 months ago


Loading...