Skip to content

Commit 9a6e665

Browse files
authored
Remove /api/_xpack/usage and /api/_kibana/v1/stats (#20800) (#21008)
/api/_xpack/usage was added as a target for 6.4.0 but it will not be used. Instead, the /api/stats response will include usage info on everything that gets registered with the usage service in /src/server/usage /api/_kibana/v1/stats is a GET API that was added in 6.2, during a point where we thought providing usage stats through a public API would be OK for capturing internally, with the benefit of having it be visible. However, we've pivoted away from that idea because it doesn't line up too well with the existing flow of data, where usage stats are combined with the "Kibana stats" such as process uptime and number of requests. We want to shift how we collect stats from Kibana, but it will be gradual. It might be a while before we have an architecture that makes sense for a standalone public API for the usage stats This endpoint was never documented, and isn't used anywhere in the code. It does incur a maintenance cost though. Therefore, instead of waiting for a next major version to remove this API, I'm removing it for 6.4. It will be marked in the release notes as a breaking change. Since it was never documented, it should not provide a problem.
1 parent 2f7e7c8 commit 9a6e665

File tree

9 files changed

+6
-143
lines changed

9 files changed

+6
-143
lines changed

x-pack/dev-tools/api_debug/apis/kibana_stats/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
*/
66

77
export const name = 'kibana_stats';
8-
export const description = 'Get the Kibana usage stats from the Kibana server';
8+
export const description = 'Get the extended Kibana usage stats from the Kibana server';
99
export const method = 'GET';
10-
export const path = '/api/_kibana/v1/stats';
10+
export const path = '/api/stats?extended=true';

x-pack/plugins/xpack_main/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import { replaceInjectedVars } from './server/lib/replace_injected_vars';
1515
import { setupXPackMain } from './server/lib/setup_xpack_main';
1616
import {
1717
xpackInfoRoute,
18-
xpackUsageRoute,
19-
kibanaStatsRoute,
2018
telemetryRoute,
2119
} from './server/routes/api/v1';
2220
import {
@@ -111,8 +109,6 @@ export const xpackMain = (kibana) => {
111109

112110
// register routes
113111
xpackInfoRoute(server);
114-
xpackUsageRoute(server); // To replace kibanaStatsRoute
115-
kibanaStatsRoute(server); // Only used internally. Remove in the next major.
116112
telemetryRoute(server);
117113
}
118114
});

x-pack/plugins/xpack_main/server/routes/api/v1/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@
55
*/
66

77
export { xpackInfoRoute } from './xpack_info';
8-
export { kibanaStatsRoute } from './kibana_stats';
9-
export { xpackUsageRoute } from './xpack_usage';
108
export { telemetryRoute } from './telemetry';

x-pack/plugins/xpack_main/server/routes/api/v1/kibana_stats.js

Lines changed: 0 additions & 47 deletions
This file was deleted.

x-pack/test/api_integration/apis/xpack_main/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
export default function ({ loadTestFile }) {
88
describe('xpack_main', () => {
99
loadTestFile(require.resolve('./telemetry'));
10-
loadTestFile(require.resolve('./usage'));
1110
});
1211
}

x-pack/test/api_integration/apis/xpack_main/usage/index.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

x-pack/test/api_integration/apis/xpack_main/usage/usage.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

x-pack/test/api_integration/services/usage_api.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@ export function UsageAPIProvider({ getService }) {
1212
return {
1313
async getUsageStatsNoAuth() {
1414
const { body } = await supertestNoAuth
15-
.get('/api/_xpack/usage')
15+
.get('/api/stats?extended=true')
1616
.set('kbn-xsrf', 'xxx')
1717
.expect(401);
18-
return body;
18+
return body.usage;
1919
},
2020

2121
async getUsageStats() {
2222
const { body } = await supertest
23-
.get('/api/_xpack/usage')
23+
.get('/api/stats?extended=true')
2424
.set('kbn-xsrf', 'xxx')
2525
.expect(200);
26-
return body;
27-
},
28-
29-
async getUsageStatsFromDeprecatedPre64Endpoint() {
30-
const { body } = await supertest
31-
.get('/api/_kibana/v1/stats')
32-
.set('kbn-xsrf', 'xxx')
33-
.expect(200);
34-
return body;
26+
return body.usage;
3527
},
3628
};
3729
}

x-pack/test/reporting/api/usage.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -123,29 +123,5 @@ export default function ({ getService }) {
123123
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 23);
124124
});
125125
});
126-
127-
/* Have to skip this test because the usage stats returned by the legacy
128-
* endpoint aren't snake_cased in the legacy usage api. This will be
129-
* completely removed in the next PR, when the legacy endpoint is removed
130-
*/
131-
describe.skip('deprecated API', () => {
132-
it('shows correct stats', async () => {
133-
const usage = await usageAPI.getUsageStatsFromDeprecatedPre64Endpoint();
134-
135-
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 2);
136-
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 2);
137-
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 2);
138-
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 2);
139-
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 1);
140-
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 4);
141-
142-
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 5);
143-
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 5);
144-
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 5);
145-
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 5);
146-
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 4);
147-
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 23);
148-
});
149-
});
150126
});
151127
}

0 commit comments

Comments
 (0)