mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
feat: added prometheus metrics support
This commit is contained in:
@@ -59,12 +59,16 @@ export interface ConfigFile {
|
||||
* List of hidden routes
|
||||
*/
|
||||
hiddenRoutes: string[];
|
||||
/**
|
||||
* Enables metrics on /metrics route
|
||||
*/
|
||||
metrics: boolean;
|
||||
/**
|
||||
* List of outdated versions
|
||||
*/
|
||||
outdatedVersions: string[];
|
||||
/**
|
||||
* Output?! TODO
|
||||
* Path the generated config will be written to
|
||||
*/
|
||||
output: string;
|
||||
/**
|
||||
@@ -93,6 +97,10 @@ export interface TemplateView {
|
||||
* Listener
|
||||
*/
|
||||
listener: string;
|
||||
/**
|
||||
* Local server with listener for /metrics route
|
||||
*/
|
||||
metrics: string;
|
||||
/**
|
||||
* Allow list for rate limiting
|
||||
*/
|
||||
|
||||
11
src/main.ts
11
src/main.ts
@@ -241,6 +241,16 @@ ${protocolHardeningParameters}
|
||||
return listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads predefined server entry with metrics location
|
||||
*/
|
||||
export async function generateMetricsServer(enableMetrics: boolean): Promise<string> {
|
||||
if (!enableMetrics) {
|
||||
return '';
|
||||
}
|
||||
return asyncReadFile('./fixtures/metrics.template', 'utf8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a mustache template file with given view object
|
||||
*
|
||||
@@ -300,6 +310,7 @@ export async function getTemplateView(containers: Dockerode.ContainerInfo[]): Pr
|
||||
),
|
||||
hiddenRoutes: (await Promise.all(hiddenRoutesPromises)).join(''),
|
||||
listener: generateListener(configFile.sslFilePaths),
|
||||
metrics: await generateMetricsServer(configFile.metrics),
|
||||
rateLimitAllowList: generateRateLimitAllowList(configFile.rateLimitAllowList),
|
||||
staticRoute: await renderTemplate(path.join('fixtures', 'staticRoute.template'), {cors}),
|
||||
visibleRoutes: (await Promise.all(visibleRoutesPromises)).join(''),
|
||||
|
||||
Reference in New Issue
Block a user