Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add collecting Prometheus metrics fot the tldraw app #4621

Merged
merged 15 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ansible/roles/schulcloud-server-core/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,10 @@
template: tldraw-ingress.yml.j2
apply: yes
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool

- name: TldrawServiceMonitor
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: tldraw-svc-monitor.yml.j2
when: WITH_TLDRAW is defined and WITH_TLDRAW|bool
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ spec:
- containerPort: 3349
name: tldraw-http
protocol: TCP
- containerPort: 9090
name: api-metrics
protocol: TCP
envFrom:
- configMapRef:
name: api-configmap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@ spec:
targetPort: 3349
protocol: TCP
name: tldraw-http
- port: {{ PORT_METRICS_SERVER }}
targetPort: 9090
protocol: TCP
name: api-metrics
selector:
app: tldraw-server
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: tldraw-svc-monitor
namespace: {{ NAMESPACE }}
labels:
app: tldraw-server
spec:
selector:
matchExpressions:
- key: app.kubernetes.io/name
operator: in
values:
- tldraw-server-svc
Comment on lines +11 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intresting, that this label is there :)

endpoints:
- path: /metrics
port: api-metrics
21 changes: 15 additions & 6 deletions apps/server/src/apps/tldraw.app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { enableOpenApiDocs } from '@shared/controller/swagger';
import { AppStartLoggable } from '@src/apps/helpers/app-start-loggable';
import { ExpressAdapter } from '@nestjs/platform-express';
import express from 'express';
import {
addPrometheusMetricsMiddlewaresIfEnabled,
createAndStartPrometheusMetricsAppIfEnabled,
} from '@src/apps/helpers/prometheus-metrics';

async function bootstrap() {
sourceMapInstall();
Expand All @@ -33,18 +37,23 @@ async function bootstrap() {
// mount instances
const rootExpress = express();

addPrometheusMetricsMiddlewaresIfEnabled(logger, rootExpress);
const port = 3349;
const basePath = '/api/v3';

// exposed alias mounts
rootExpress.use(basePath, nestExpress);
rootExpress.listen(port);

logger.info(
new AppStartLoggable({
appName: 'Tldraw server app',
})
);
rootExpress.listen(port, () => {
logger.info(
new AppStartLoggable({
appName: 'Tldraw server app',
port,
})
);

createAndStartPrometheusMetricsAppIfEnabled(logger);
});
}

void bootstrap();
Loading