Skip to content

Commit

Permalink
Merge branch '8.x' into backport/8.x/pr-200274
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang authored Nov 20, 2024
2 parents c0425fb + 20cbae5 commit 169dcd9
Show file tree
Hide file tree
Showing 42 changed files with 550 additions and 217 deletions.
8 changes: 3 additions & 5 deletions docs/user/reporting/automating-report-generation.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ To create the POST URL for PDF reports:

. Open the dashboard, visualization, or **Canvas** workpad you want to view as a report.

. From the toolbar, click *Share > PDF Reports*, then choose an option:
* If you are using *Dashboard* or *Visualize Library*, from the toolbar, click *Share > Export*, select the PDF option then click *Copy POST URL*.

* If you are using *Dashboard* or *Visulize Library*, click *Copy POST URL*.

* If you are using *Canvas*, click *Advanced options > Copy POST URL*.
* If you are using *Canvas*, from the toolbar, click *Share > PDF Reports*, then click *Advanced options > Copy POST URL*.

To create the POST URL for CSV reports:

. Go to *Discover*.

. Open the saved search you want to share.

. In the toolbar, click *Share > CSV Reports > Copy POST URL*.
. In the toolbar, click *Share > Export > Copy POST URL*.

[float]
[[use-watcher]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const DEFAULT_APP_CATEGORIES: Record<string, AppCategory> = Object.freeze
enterpriseSearch: {
id: 'enterpriseSearch',
label: i18n.translate('core.ui.searchNavList.label', {
defaultMessage: 'Search',
defaultMessage: 'Elasticsearch',
}),
order: 2000,
euiIconType: 'logoEnterpriseSearch',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const GuideFilters = ({ activeFilter, setActiveFilter, application }: Gui
>
<FormattedMessage
id="guidedOnboardingPackage.gettingStarted.guideFilter.search.buttonLabel"
defaultMessage="Search"
defaultMessage="Elasticsearch"
/>
</EuiButton>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const GuideFilters = ({
>
<FormattedMessage
id="guidedOnboardingPackage.gettingStarted.guideFilter.search.buttonLabel"
defaultMessage="Search"
defaultMessage="Elasticsearch"
/>
</EuiButton>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const names: Record<string, string> = {
defaultMessage: 'Reporting',
}),
[SEARCH_CATEGORY]: i18n.translate('management.settings.categoryNames.searchLabel', {
defaultMessage: 'Search',
defaultMessage: 'Elasticsearch',
}),
[SECURITY_SOLUTION_CATEGORY]: i18n.translate(
'management.settings.categoryNames.securitySolutionLabel',
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/custom_integrations/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const INTEGRATION_CATEGORY_DISPLAY: {
productivity_security: { title: 'Productivity', parent_id: 'security' },
proxy_security: { title: 'Proxy', parent_id: 'security' },
sdk_search: { title: 'SDK', parent_id: 'search' },
search: { title: 'Search', parent_id: undefined },
search: { title: 'Elasticsearch', parent_id: undefined },
security: { title: 'Security', parent_id: undefined },
stream_processing: { title: 'Stream Processing', parent_id: 'observability' },
support: { title: 'Support', parent_id: undefined },
Expand Down
34 changes: 32 additions & 2 deletions src/plugins/unified_histogram/public/chart/histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
import { useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import React, { useState } from 'react';
import type { DataView } from '@kbn/data-views-plugin/public';
import type { DataView, DataViewSpec } from '@kbn/data-views-plugin/public';
import type { DefaultInspectorAdapters, Datatable } from '@kbn/expressions-plugin/common';
import type { IKibanaSearchResponse } from '@kbn/search-types';
import type { estypes } from '@elastic/elasticsearch';
import type { TimeRange } from '@kbn/es-query';
import type {
import {
EmbeddableComponentProps,
LensEmbeddableInput,
LensEmbeddableOutput,
Expand Down Expand Up @@ -59,6 +59,32 @@ export interface HistogramProps {
withDefaultActions: EmbeddableComponentProps['withDefaultActions'];
}

/**
* To prevent flakiness in the chart, we need to ensure that the data view config is valid.
* This requires that there are not multiple different data view ids in the given configuration.
* @param dataView
* @param visContext
* @param adHocDataViews
*/
const checkValidDataViewConfig = (
dataView: DataView,
visContext: UnifiedHistogramVisContext,
adHocDataViews: { [key: string]: DataViewSpec } | undefined
) => {
if (!dataView.id) {
return false;
}

if (!dataView.isPersisted() && !adHocDataViews?.[dataView.id]) {
return false;
}

if (dataView.id !== visContext.requestData.dataViewId) {
return false;
}
return true;
};

const computeTotalHits = (
hasLensSuggestions: boolean,
adapterTables:
Expand Down Expand Up @@ -204,6 +230,10 @@ export function Histogram({
}
`;

if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
return <></>;
}

return (
<>
<div
Expand Down
7 changes: 3 additions & 4 deletions test/functional/apps/discover/group3/_lens_vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
return seriesType;
}

// FLAKY: https://github.com/elastic/kibana/issues/184600
describe.skip('discover lens vis', function () {
describe('discover lens vis', function () {
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
Expand Down Expand Up @@ -655,8 +654,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await discover.waitUntilSearchingHasFinished();
await testSubjects.missingOrFail('unsavedChangesBadge');

await discover.chooseLensSuggestion('pie');
expect(await getCurrentVisTitle()).to.be('Pie');
await discover.chooseLensSuggestion('waffle');
expect(await getCurrentVisTitle()).to.be('Waffle');
await testSubjects.existOrFail('partitionVisChart');
expect(await discover.getVisContextSuggestionType()).to.be('lensSuggestion');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ describe('getTokenCountFromOpenAIStream', () => {
],
};

const usageChunk = {
object: 'chat.completion.chunk',
choices: [],
usage: {
prompt_tokens: 50,
completion_tokens: 100,
total_tokens: 150,
},
};

const PROMPT_TOKEN_COUNT = 36;
const COMPLETION_TOKEN_COUNT = 5;

Expand All @@ -70,55 +80,79 @@ describe('getTokenCountFromOpenAIStream', () => {
});

describe('when a stream completes', () => {
beforeEach(async () => {
stream.write('data: [DONE]');
stream.complete();
});
describe('with usage chunk', () => {
it('returns the counts from the usage chunk', async () => {
stream = createStreamMock();
stream.write(`data: ${JSON.stringify(chunk)}`);
stream.write(`data: ${JSON.stringify(usageChunk)}`);
stream.write('data: [DONE]');
stream.complete();

describe('without function tokens', () => {
beforeEach(async () => {
tokens = await getTokenCountFromOpenAIStream({
responseStream: stream.transform,
logger,
body: JSON.stringify(body),
});
});

it('counts the prompt tokens', () => {
expect(tokens.prompt).toBe(PROMPT_TOKEN_COUNT);
expect(tokens.completion).toBe(COMPLETION_TOKEN_COUNT);
expect(tokens.total).toBe(PROMPT_TOKEN_COUNT + COMPLETION_TOKEN_COUNT);
expect(tokens).toEqual({
prompt: usageChunk.usage.prompt_tokens,
completion: usageChunk.usage.completion_tokens,
total: usageChunk.usage.total_tokens,
});
});
});

describe('with function tokens', () => {
describe('without usage chunk', () => {
beforeEach(async () => {
tokens = await getTokenCountFromOpenAIStream({
responseStream: stream.transform,
logger,
body: JSON.stringify({
...body,
functions: [
{
name: 'my_function',
description: 'My function description',
parameters: {
type: 'object',
properties: {
my_property: {
type: 'boolean',
description: 'My function property',
stream.write('data: [DONE]');
stream.complete();
});

describe('without function tokens', () => {
beforeEach(async () => {
tokens = await getTokenCountFromOpenAIStream({
responseStream: stream.transform,
logger,
body: JSON.stringify(body),
});
});

it('counts the prompt tokens', () => {
expect(tokens.prompt).toBe(PROMPT_TOKEN_COUNT);
expect(tokens.completion).toBe(COMPLETION_TOKEN_COUNT);
expect(tokens.total).toBe(PROMPT_TOKEN_COUNT + COMPLETION_TOKEN_COUNT);
});
});

describe('with function tokens', () => {
beforeEach(async () => {
tokens = await getTokenCountFromOpenAIStream({
responseStream: stream.transform,
logger,
body: JSON.stringify({
...body,
functions: [
{
name: 'my_function',
description: 'My function description',
parameters: {
type: 'object',
properties: {
my_property: {
type: 'boolean',
description: 'My function property',
},
},
},
},
},
],
}),
],
}),
});
});
});

it('counts the function tokens', () => {
expect(tokens.prompt).toBeGreaterThan(PROMPT_TOKEN_COUNT);
it('counts the function tokens', () => {
expect(tokens.prompt).toBeGreaterThan(PROMPT_TOKEN_COUNT);
});
});
});
});
Expand Down
Loading

0 comments on commit 169dcd9

Please sign in to comment.