mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
/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.
127 lines
5.9 KiB
JavaScript
127 lines
5.9 KiB
JavaScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License;
|
|
* you may not use this file except in compliance with the Elastic License.
|
|
*/
|
|
|
|
import expect from 'expect.js';
|
|
import * as GenerationUrls from "./generation_urls";
|
|
|
|
export default function ({ getService }) {
|
|
const esArchiver = getService('esArchiver');
|
|
const reportingAPI = getService('reportingAPI');
|
|
const usageAPI = getService('usageAPI');
|
|
|
|
describe('reporting usage', () => {
|
|
before(async () => {
|
|
await reportingAPI.deleteAllReportingIndexes();
|
|
});
|
|
|
|
describe('initial usage', () => {
|
|
let usage;
|
|
|
|
before(async () => {
|
|
usage = await usageAPI.getUsageStats();
|
|
});
|
|
|
|
it('shows reporting as available and enabled', async () => {
|
|
expect(usage.reporting.available).to.be(true);
|
|
expect(usage.reporting.enabled).to.be(true);
|
|
});
|
|
|
|
it('is using phantom browser', async () => {
|
|
expect(usage.reporting.browser_type).to.be('phantom');
|
|
});
|
|
|
|
it('all counts are 0', async () => {
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 0);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 0);
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 0);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 0);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 0);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 0);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 0);
|
|
});
|
|
});
|
|
|
|
describe('includes usage from reporting indexes', () => {
|
|
it('generated from 6.2', async () => {
|
|
await esArchiver.load('bwc/6_2');
|
|
const usage = await usageAPI.getUsageStats();
|
|
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 0);
|
|
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 1);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 7);
|
|
|
|
// These statistics weren't tracked until 6.3
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 0);
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 0);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 0);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 0);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 0);
|
|
});
|
|
|
|
|
|
it('generated from 6.3', async () => {
|
|
await esArchiver.load('bwc/6_3');
|
|
const usage = await usageAPI.getUsageStats();
|
|
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 0);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 0);
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 0);
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 0);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 0);
|
|
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 3);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 19);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 3);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 3);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 3);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 3);
|
|
});
|
|
});
|
|
|
|
describe('usage updated when new jobs are posted', async () => {
|
|
it('post jobs', async () => {
|
|
const reportPaths = [];
|
|
reportPaths.push(await reportingAPI.postJob(GenerationUrls.CSV_DISCOVER_KUERY_AND_FILTER_6_3));
|
|
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_DASHBOARD_FILTER_6_3));
|
|
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRESERVE_PIE_VISUALIZATION_6_3));
|
|
reportPaths.push(await reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_6_3));
|
|
reportPaths.push(await reportingAPI.postJob(
|
|
GenerationUrls.PDF_PRINT_PIE_VISUALIZATION_FILTER_AND_SAVED_SEARCH_6_3));
|
|
|
|
await reportingAPI.expectAllJobsToFinishSuccessfully(reportPaths);
|
|
}).timeout(1540000);
|
|
|
|
it('usage updated', async () => {
|
|
const usage = await usageAPI.getUsageStats();
|
|
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'visualization', 2);
|
|
reportingAPI.expectRecentPdfAppStats(usage, 'dashboard', 2);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'preserve_layout', 2);
|
|
reportingAPI.expectRecentPdfLayoutStats(usage, 'print', 2);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'csv', 1);
|
|
reportingAPI.expectRecentJobTypeTotalStats(usage, 'printable_pdf', 4);
|
|
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'visualization', 5);
|
|
reportingAPI.expectAllTimePdfAppStats(usage, 'dashboard', 5);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'preserve_layout', 5);
|
|
reportingAPI.expectAllTimePdfLayoutStats(usage, 'print', 5);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'csv', 4);
|
|
reportingAPI.expectAllTimeJobTypeTotalStats(usage, 'printable_pdf', 23);
|
|
});
|
|
});
|
|
});
|
|
}
|