Skip to content

Commit aa2f3f1

Browse files
authored
Update label handling on frontend + Refactors (opensearch-project#931)
* Update label display on frontend Signed-off-by: Simeon Widdis <[email protected]> * Clear type errors in added_integration.tsx Signed-off-by: Simeon Widdis <[email protected]> * Remove unused imports Signed-off-by: Simeon Widdis <[email protected]> * Add missing labels Signed-off-by: Simeon Widdis <[email protected]> * Autoformat the whole repository Signed-off-by: Simeon Widdis <[email protected]> * Revert large sample data changes Signed-off-by: Simeon Widdis <[email protected]> * Undo _import autoescape Signed-off-by: Simeon Widdis <[email protected]> --------- Signed-off-by: Simeon Widdis <[email protected]>
1 parent adf68fe commit aa2f3f1

File tree

67 files changed

+1254
-1326
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1254
-1326
lines changed

.husky/pre-commit

100644100755
File mode changed.

public/components/integrations/components/added_integration.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@
55
/* eslint-disable react-hooks/exhaustive-deps */
66

77
import {
8-
EuiBadge,
9-
EuiButton,
108
EuiButtonIcon,
119
EuiFlexGroup,
1210
EuiFlexItem,
13-
EuiGlobalToastList,
1411
EuiHealth,
15-
EuiIcon,
1612
EuiInMemoryTable,
1713
EuiLink,
1814
EuiOverlayMask,
@@ -64,7 +60,7 @@ export function AddedIntegration(props: AddedIntegrationProps) {
6460
const [isModalVisible, setIsModalVisible] = useState(false);
6561
const [modalLayout, setModalLayout] = useState(<EuiOverlayMask />);
6662

67-
const badge = (status) => {
63+
const badge = (status: string) => {
6864
switch (status) {
6965
case 'available':
7066
return <EuiHealth color="success">Active</EuiHealth>;
@@ -136,7 +132,6 @@ export function AddedIntegration(props: AddedIntegrationProps) {
136132
<EuiButtonIcon
137133
iconType="trash"
138134
aria-label="Delete"
139-
size="l"
140135
color="danger"
141136
onClick={() => {
142137
getModal();
@@ -173,7 +168,7 @@ export function AddedIntegration(props: AddedIntegrationProps) {
173168

174169
const assets = data?.assets || [];
175170

176-
const renderAsset = (record) => {
171+
const renderAsset = (record: any) => {
177172
switch (record.assetType) {
178173
case 'dashboard':
179174
return (
@@ -234,7 +229,7 @@ export function AddedIntegration(props: AddedIntegrationProps) {
234229
},
235230
filters: [
236231
{
237-
type: 'field_value_selection',
232+
type: 'field_value_selection' as const,
238233
field: 'assetType',
239234
name: 'Type',
240235
multiSelect: false,

public/components/integrations/components/available_integration_card_view.tsx

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,11 @@ import {
99
EuiFlexGroup,
1010
EuiFlexItem,
1111
EuiSpacer,
12-
EuiSearchBar,
13-
EuiButton,
1412
EuiFieldSearch,
15-
EuiSwitch,
1613
EuiButtonGroup,
17-
EuiBadgeGroup,
18-
EuiBadge,
19-
EuiToolTip,
2014
} from '@elastic/eui';
2115
import _ from 'lodash';
22-
import React, { useRef, useState } from 'react';
16+
import React, { useState } from 'react';
2317
import {
2418
AvailableIntegrationsCardViewProps,
2519
AvailableIntegrationType,
@@ -54,7 +48,7 @@ export function AvailableIntegrationsCardView(props: AvailableIntegrationsCardVi
5448
},
5549
];
5650

57-
const onChangeIcons = (optionId) => {
51+
const onChangeIcons = (optionId: string) => {
5852
setToggleIconIdSelected(optionId);
5953
if (optionId === '0') {
6054
props.setCardView(false);
@@ -82,7 +76,7 @@ export function AvailableIntegrationsCardView(props: AvailableIntegrationsCardVi
8276
data-test-subj={`integration_card_${i.name.toLowerCase()}`}
8377
titleElement="span"
8478
onClick={() => (window.location.hash = `#/available/${i.name}`)}
85-
footer={badges(i.components)}
79+
footer={badges(i.labels ?? [])}
8680
/>
8781
</EuiFlexItem>
8882
);

public/components/integrations/components/available_integration_overview_page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { useToast } from '../../../../public/components/common/toast';
2525
import { HttpStart } from '../../../../../../src/core/public';
2626

2727
export interface AvailableIntegrationType {
28+
labels?: string[];
2829
name: string;
2930
description: string;
3031
assetUrl?: string | undefined;
@@ -117,8 +118,7 @@ export function AvailableIntegrationOverviewPage(props: AvailableIntegrationOver
117118
setData(exists.data);
118119

119120
let newItems = exists.data.hits
120-
.flatMap((hit: { components: Array<{ name: string }> }) => hit.components)
121-
.map((component: { name: string }) => component.name);
121+
.flatMap((hit: { labels?: string[] }) => hit.labels ?? []);
122122
newItems = [...new Set(newItems)].sort().map((newItem) => {
123123
return {
124124
name: newItem,

public/components/integrations/components/available_integration_table.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,11 @@
55

66
import {
77
EuiButtonGroup,
8-
EuiFieldSearch,
9-
EuiFilterButton,
10-
EuiFilterGroup,
11-
EuiFilterSelectItem,
128
EuiFlexGroup,
139
EuiFlexItem,
14-
EuiIcon,
1510
EuiInMemoryTable,
1611
EuiLink,
1712
EuiPageContent,
18-
EuiPopover,
19-
EuiPopoverTitle,
2013
EuiSpacer,
2114
EuiTableFieldDataColumnType,
2215
EuiText,
@@ -44,7 +37,7 @@ export function AvailableIntegrationsTable(props: AvailableIntegrationsTableProp
4437

4538
const [toggleIconIdSelected, setToggleIconIdSelected] = useState('0');
4639

47-
const onChangeIcons = (optionId) => {
40+
const onChangeIcons = (optionId: string) => {
4841
setToggleIconIdSelected(optionId);
4942
if (optionId === '0') {
5043
props.setCardView(false);

public/components/integrations/components/integration_category_badge_group.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@
66
import { EuiBadge, EuiBadgeGroup, EuiToolTip } from '@elastic/eui';
77
import React from 'react';
88

9-
export const badges = (categories) => {
10-
if (categories.length <= 3) {
9+
export const badges = (labels: string[]) => {
10+
if (labels.length <= 3) {
1111
return (
1212
<EuiBadgeGroup>
13-
{categories.map((cateogry) => {
14-
return <EuiBadge>{cateogry.name}</EuiBadge>;
13+
{labels.map((label) => {
14+
return <EuiBadge>{label}</EuiBadge>;
1515
})}
1616
</EuiBadgeGroup>
1717
);
1818
} else {
19-
const tooltip = `+${categories.length - 2} more`;
19+
const tooltip = `+${labels.length - 2} more`;
2020
return (
2121
<EuiBadgeGroup>
22-
<EuiBadge>{categories[0].name}</EuiBadge>
23-
<EuiBadge>{categories[1].name}</EuiBadge>
22+
<EuiBadge>{labels[0]}</EuiBadge>
23+
<EuiBadge>{labels[1]}</EuiBadge>
2424
<EuiBadge>
2525
<EuiToolTip
26-
content={categories.slice(2).map((item, index) => (index ? ', ' : '') + item.name)}
26+
content={labels.slice(2).map((item: string, index: number) => (index ? ', ' : '') + item)}
2727
>
2828
<h4>{tooltip}</h4>
2929
</EuiToolTip>

public/components/integrations/components/integration_details_panel.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ export function IntegrationDetails(props: any) {
4343
</EuiText>
4444
<EuiSpacer size="m" />
4545
<EuiBadgeGroup>
46-
{config.components.map((cateogry) => {
47-
return <EuiBadge>{cateogry.name}</EuiBadge>;
46+
{config.labels?.map((label: string) => {
47+
return <EuiBadge>{label}</EuiBadge>;
4848
})}
4949
</EuiBadgeGroup>
5050
</EuiFlexItem>
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,46 @@
11
{
2-
"name": "apache",
3-
"version": "1.0.0",
4-
"displayName": "Apache Dashboard",
5-
"description": "Apache web logs collector",
6-
"license": "Apache-2.0",
7-
"type": "logs_apache",
8-
"author": "OpenSearch",
9-
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/apache/info",
10-
"statics": {
11-
"logo": {
12-
"annotation": "Apache Logo",
13-
"path": "logo.png"
14-
},
15-
"gallery": [
16-
{
17-
"annotation": "Apache Dashboard",
18-
"path": "dashboard1.png"
19-
}
20-
]
2+
"name": "apache",
3+
"version": "1.0.0",
4+
"displayName": "Apache Dashboard",
5+
"description": "Apache web logs collector",
6+
"license": "Apache-2.0",
7+
"type": "logs_apache",
8+
"labels": ["log", "communication", "http"],
9+
"author": "OpenSearch",
10+
"sourceUrl": "https://github.com/opensearch-project/dashboards-observability/tree/main/server/adaptors/integrations/__data__/repository/apache/info",
11+
"statics": {
12+
"logo": {
13+
"annotation": "Apache Logo",
14+
"path": "logo.png"
2115
},
22-
"components": [
23-
{
24-
"name": "communication",
25-
"version": "1.0.0"
26-
},
27-
{
28-
"name": "http",
29-
"version": "1.0.0"
30-
},
31-
{
32-
"name": "logs_apache",
33-
"version": "1.0.0"
34-
}
35-
],
36-
"assets": {
37-
"savedObjects": {
38-
"name": "apache",
39-
"version": "1.0.0"
40-
}
16+
"gallery": [
17+
{
18+
"annotation": "Apache Dashboard",
19+
"path": "dashboard1.png"
20+
}
21+
]
22+
},
23+
"components": [
24+
{
25+
"name": "communication",
26+
"version": "1.0.0"
4127
},
42-
"sampleData": {
43-
"path": "sample.json"
28+
{
29+
"name": "http",
30+
"version": "1.0.0"
31+
},
32+
{
33+
"name": "logs_apache",
34+
"version": "1.0.0"
35+
}
36+
],
37+
"assets": {
38+
"savedObjects": {
39+
"name": "apache",
40+
"version": "1.0.0"
4441
}
42+
},
43+
"sampleData": {
44+
"path": "sample.json"
45+
}
4546
}

server/adaptors/integrations/__data__/repository/apache/info/INGESTION.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
# Ingestion Pipeline
2-
To set up an ingestion pipeline, I used Docker to run Fluent-bit and an Apache fake log generator, along with an instance of OpenSearch.
2+
3+
To set up an ingestion pipeline, I used Docker to run Fluent-bit and an Apache fake log generator, along with an instance of OpenSearch.
34

45
## FluentBit and OpenSearch Setup
6+
57
First, create a `docker-compose.yml` instance like [this](https://github.com/opensearch-project/data-prepper/blob/93d06db5cad280e2e4c53e12dfb47c7cbaa7b364/examples/log-ingestion/docker-compose.yaml). This will pull FluentBit and OpenSearch Docker images and run them in `opensearch-net` Docker network.
68

79
Next, use an Apache log generator to generate sample logs. I used `mingrammer/flog` in my `docker-compose.yml` file:
10+
811
```
912
apache:
1013
image: mingrammer/flog
@@ -23,6 +26,7 @@ Next, use an Apache log generator to generate sample logs. I used `mingrammer/fl
2326
```
2427

2528
Then, create a `fluent-bit.conf` as follows:
29+
2630
```
2731
[SERVICE]
2832
Parsers_File parsers.conf
@@ -51,9 +55,11 @@ Then, create a `fluent-bit.conf` as follows:
5155
Index ss4o_logs-apache-prod-sample
5256
Suppress_Type_Name On
5357
```
58+
5459
This creates a Fluent-Bit pipeline that forwards your generated apache logs through a parser to OpenSearch.
5560

5661
Create a `parsers.conf` file as follows:
62+
5763
```
5864
[PARSER]
5965
Name apache
@@ -66,6 +72,7 @@ Create a `parsers.conf` file as follows:
6672
You can also use a [GeoIP2 Filter](https://docs.fluentbit.io/manual/pipeline/filters/geoip2-filter) to enrich the data with geolocation data.
6773

6874
Finally, I used a `otel-converter.lua` script to convert the parsed data into schema-compliant data:
75+
6976
```lua
7077
local hexCharset = "0123456789abcdef"
7178
local function randHex(length)
@@ -96,7 +103,7 @@ function convert_to_otel(tag, timestamp, record)
96103
if tag=="apache.access" then
97104
record.remote=record.host
98105
end
99-
106+
100107
local data = {
101108
traceId=randHex(32),
102109
spanId=randHex(16),
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Apache Integration
22

33
## What is Apache ?
4+
45
Apache is an open source web server software for modern operating systems including UNIX and Windows.
56

67
See additional details [here](https://httpd.apache.org/).
78

89
## What is Apache Integration ?
10+
911
An integration is a bundle of pre-canned assets which are bundled togather in a meaningful manner.
1012

1113
Apache integration includes dashboards, visualisations, queries and an index mapping.
1214

1315
### Dashboards
16+
1417
![](../static/dashboard1.png)

0 commit comments

Comments
 (0)