Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
[BUG] Fix base path. (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjhampton authored Jul 19, 2021
1 parent 1a44a62 commit 0685222
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,11 @@ export class KibanaPrometheusExporterPlugin
}

public setup(core: CoreSetup) {
this.logger.debug('kibanaPrometheusExporter: Setup');
this.logger.debug('kibanaPrometheusExporter: Setting up');
const fullStatsURI = core.http.basePath.prepend("/api/status")
const router = core.http.createRouter();

// Register server side APIs
defineRoutes(router);

defineRoutes(router, fullStatsURI);
return {};
}

Expand All @@ -32,5 +31,7 @@ export class KibanaPrometheusExporterPlugin
return {};
}

public stop() {}
public stop() {
this.logger.debug('kibanaPrometheusExporter: Stopped')
}
}
4 changes: 2 additions & 2 deletions server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import formatter from '../../common/formatter'
import axios from 'axios';
import agent from '../helpers/server_client';

export function defineRoutes(router: IRouter) {
export function defineRoutes(router: IRouter, statsURI: string) {
router.get(
{
path: '/_prometheus/metrics',
Expand All @@ -14,7 +14,7 @@ export function defineRoutes(router: IRouter) {
let reqProto = request.url.protocol || 'http:';
let reqHost = request.url.host?.replace(/:\d+/, '') || '127.0.0.1';
let reqPort = request.url.port || 5601;
let reqUrl = `${reqProto}//${reqHost}:${reqPort}/api/status`;
let reqUrl = `${reqProto}//${reqHost}:${reqPort}${statsURI}`;

if (request.headers !== undefined
&& request.headers.authorization !== undefined) {
Expand Down

0 comments on commit 0685222

Please sign in to comment.