Skip to content

Add more details in the query editor #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ This dashboard is aimed at visualizing the logs stored in the Parseable demo ser

## Screenshots

![query editor](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/query-editor.png?raw=true)
![log dashboard](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-visualisation.png?raw=true)
![log text view](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-view-text.png?raw=true)
1 change: 1 addition & 0 deletions dist/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ This dashboard is aimed at visualizing the logs stored in the Parseable demo ser

## Screenshots

![query editor](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/query-editor.png?raw=true)
![log dashboard](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-visualisation.png?raw=true)
![log text view](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-view-text.png?raw=true)
Binary file added dist/img/query-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/module.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/module.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{"name": "Log Dashboard", "path": "img/log-visualisation.png"}
],
"version": "1.0.0",
"updated": "2023-01-11"
"updated": "2023-01-12"
},
"routes": [
{
Expand Down
Binary file modified releases/parseable-datasource-1.0.0.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion releases/parseable-datasource-1.0.0.zip.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dd08ae43a151ee69e30f74592a34e9726373fc4d
5b8ea6ec14ae03fef6d647897117747404f754fd
1 change: 1 addition & 0 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ This dashboard is aimed at visualizing the logs stored in the Parseable demo ser

## Screenshots

![query editor](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/query-editor.png?raw=true)
![log dashboard](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-visualisation.png?raw=true)
![log text view](https://github.com/parseablehq/parseable-datasource/blob/main/src/img/log-view-text.png?raw=true)
128 changes: 68 additions & 60 deletions src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ComponentType, ChangeEvent, useState } from 'react';
import { LegacyForms, AsyncSelect, Label, InlineField, InlineFieldRow } from '@grafana/ui';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { LegacyForms, AsyncSelect, InlineField, InlineFieldRow, SeriesTable, Label} from '@grafana/ui';
import { QueryEditorProps, SelectableValue, GraphSeriesValue } from '@grafana/data';
import { DataSource } from '../datasource';
import { SchemaFields, MyDataSourceOptions, MyQuery } from '../types';

Expand Down Expand Up @@ -30,10 +30,11 @@ export const QueryEditor: ComponentType<Props> = ({ datasource, onChange, onRunQ

const [value, setValue] = useState<SelectableValue<string>>();
const [schema = '', setSchema] = React.useState<string | number>();
const [count = '', setEventCount] = React.useState<string | number>();
const [count = '', setEventCount] = React.useState<string | GraphSeriesValue>();
const [jsonsize = '', setJsonSize] = React.useState<string | number>();
const [parquetsize = '', setParquetSize] = React.useState<string | number>();
const [streamname = '', setStreamName] = React.useState<string | number>();
const [time = '', setTime] = React.useState<string | number>();
//const [fielder, setFielder] = React.useState<string | number>();

const loadStreamSchema = React.useCallback((value) => {
Expand Down Expand Up @@ -65,10 +66,12 @@ export const QueryEditor: ComponentType<Props> = ({ datasource, onChange, onRunQ
const jsonsize = result.ingestion.size;
const parquetsize = result.storage?.size;
const streamname = result.stream;
const time = result.time;
setJsonSize(jsonsize);
setParquetSize(parquetsize);
setStreamName(streamname);
setEventCount(count);
setTime(time);
return count;
}
return count;
Expand Down Expand Up @@ -103,75 +106,80 @@ export const QueryEditor: ComponentType<Props> = ({ datasource, onChange, onRunQ

return (
<>
<div className="gf-form">
<InlineFieldRow>
<InlineField>
<Label >
<div style={{ width: 'fit-content', color: 'blue' }}>
<Label>
Select a log stream:
</div>
<div style={{ width: 200 + 'px', marginRight: '20px', marginLeft: '20px' }}>
<AsyncSelect
loadOptions={loadAsyncOptions}
defaultOptions
value={value}
onChange={v => {
setValue(v);
}}
/>
</div>
</Label>
</Label>
</InlineField>
<InlineField>
<AsyncSelect
loadOptions={loadAsyncOptions}
defaultOptions
value={value}
onChange={v => {
setValue(v);
}}/>
</InlineField>
{/* <InlineField>
<TextArea
invalid={false}
placeholder='Select a log stream (above) to view its columns'
rows={2}
cols={200}
disabled={true}
value={schema}/>
</InlineField> */}
</InlineFieldRow>

<InlineFieldRow>
<div>
<Label>
<div style={{ width: 'fit-content', textAlign: 'center', color: 'blue'}}>
Stream {streamname} details
</div>
</Label>
<Label>
<div style={{ width: 'fit-content', color: 'blue' }}>
Columns:
</div>
<div style={{ width: 'fit-content' }}>
{ schema}
</div>
</Label>
<Label>
<div style={{ width: 'fit-content', color: 'blue' }}>
Total events ingested:
</div>
<div style={{ width: 'fit-content' }}>
{ count}
</div>
</Label>
<Label>
<div style={{ width: 'fit-content', color: 'blue' }}>
Total ingested data size:
</div>
<div style={{ width: 'fit-content' }}>
{ jsonsize}
</div>
</Label>
<Label>
<div style={{ width: 'fit-content', color: 'blue' }}>
Total compressed data stored:
</div>
<div style={{ width: 'fit-content' }}>
{ parquetsize}
</div>
</Label>
</div>
<InlineFieldRow>
<InlineField>
<SeriesTable
series={[
{
color: '#299c46',
isActive: true,
label: 'Stream name',
value: streamname
},
{
color: '#299c46',
isActive: false,
label: 'Column names',
value: schema
},
{
color: '#299c46',
isActive: false,
label: 'Total ingested event count',
value: count
},
{
color: '#299c46',
isActive: false,
label: 'Total ingested json size',
value: jsonsize
},
{
color: '#299c46',
isActive: false,
label: 'Total stored data size',
value: parquetsize
}
]}
timestamp={time}
/>
</InlineField>
</InlineFieldRow>
</div>

<br></br>
<FormField
labelWidth={12}
inputWidth={100}
value={queryText || ''}
onChange={onQueryTextChange}
label="SQL Query"
tooltip="Enter the search SQL query here (use column names as displayed above)"
tooltip="Enter the SQL query here (use column names as above)"
/>
</>
);
Expand Down
Binary file added src/img/query-editor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.