Skip to content

Commit

Permalink
Merge pull request #221 from snetsystems/dev-1.0.1-dbchoe
Browse files Browse the repository at this point in the history
dbchoe: StatusPage. modify getAlerts query
  • Loading branch information
snetsystems authored Jul 10, 2020
2 parents 3f1fa66 + 677c831 commit bdb290c
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 105 deletions.
6 changes: 5 additions & 1 deletion frontend/src/status/containers/StatusPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ class StatusPage extends Component<Props, State> {
super(props)

this.state = {
cells: fixtureStatusPageCells,
cells: [],
}
}

public componentDidMount() {
this.setState({cells: fixtureStatusPageCells(this.props.source)})
}

public render() {
const {source} = this.props
const {cells} = this.state
Expand Down
210 changes: 106 additions & 104 deletions frontend/src/status/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {DEFAULT_LINE_COLORS} from 'src/shared/constants/graphColorPalettes'
import {TEMP_VAR_DASHBOARD_TIME} from 'src/shared/constants'
import {NEW_DEFAULT_DASHBOARD_CELL} from 'src/dashboards/constants/index'
import {DEFAULT_AXIS} from 'src/dashboards/constants/cellEditor'
import {Cell, CellQuery, Axes, CellType, QueryType} from 'src/types'
import {Source, Cell, CellQuery, Axes, CellType, QueryType} from 'src/types'

const emptyQuery: CellQuery = {
query: '',
Expand All @@ -16,114 +16,116 @@ const emptyQuery: CellQuery = {
groupBy: {},
areTagsAccepted: false,
rawText: null,
range: null
range: null,
},
type: QueryType.InfluxQL
type: QueryType.InfluxQL,
}

const emptyAxes: Axes = {
x: DEFAULT_AXIS,
y: DEFAULT_AXIS
y: DEFAULT_AXIS,
}

export const fixtureStatusPageCells: Cell[] = [
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'alerts-bar-graph',
type: CellType.Bar,
isWidget: false,
x: 0,
y: 0,
w: 12,
h: 4,
legend: {},
name: 'Alert Events per Day – Last 30 Days',
colors: DEFAULT_LINE_COLORS,
queries: [
{
id: '1234',
query: `SELECT count("value") AS "count_value" FROM "cloudhub"."autogen"."alerts" WHERE time > ${TEMP_VAR_DASHBOARD_TIME} GROUP BY time(1d)`,
source: '',
type: QueryType.InfluxQL,
queryConfig: {
database: 'cloudhub',
measurement: 'alerts',
retentionPolicy: 'autogen',
fields: [
{
value: 'count',
type: 'func',
alias: 'count_value',
args: [
{
value: 'value',
type: 'field'
}
]
}
],
tags: {},
groupBy: {
time: '1d',
tags: []
export const fixtureStatusPageCells = (source: Source): Cell[] => {
return [
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'alerts-bar-graph',
type: CellType.Bar,
isWidget: false,
x: 0,
y: 0,
w: 12,
h: 4,
legend: {},
name: 'Alert Events per Day – Last 30 Days',
colors: DEFAULT_LINE_COLORS,
queries: [
{
id: '1234',
query: `SELECT count("value") AS "count_value" FROM "cloudhub_alerts" WHERE time > ${TEMP_VAR_DASHBOARD_TIME} GROUP BY time(1d)`,
source: '',
type: QueryType.InfluxQL,
queryConfig: {
database: source.telegraf,
measurement: 'cloudhub_alerts',
retentionPolicy: 'autogen',
fields: [
{
value: 'count',
type: 'func',
alias: 'count_value',
args: [
{
value: 'value',
type: 'field',
},
],
},
],
tags: {},
groupBy: {
time: '1d',
tags: [],
},
areTagsAccepted: false,
rawText: null,
range: null,
},
areTagsAccepted: false,
rawText: null,
range: null
}
}
],
links: {
self: '/cloudhub/v1/status/23/cells/c-bar-graphs-fly'
}
},
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'recent-alerts',
type: CellType.Alerts,
isWidget: true,
name: 'Alerts – Last 30 Days',
x: 0,
y: 5,
w: 6.5,
h: 6,
legend: {},
queries: [emptyQuery],
colors: DEFAULT_LINE_COLORS,
links: {self: ''}
},
// {
// ...NEW_DEFAULT_DASHBOARD_CELL,
// axes: emptyAxes,
// i: 'news-feed',
// type: CellType.News,
// isWidget: true,
// name: 'News Feed',
// x: 6.5,
// y: 5,
// w: 3,
// h: 6,
// legend: {},
// queries: [emptyQuery],
// colors: DEFAULT_LINE_COLORS,
// links: {self: ''},
// },
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'getting-started',
type: CellType.Guide,
isWidget: true,
name: 'Getting Started',
x: 6.5,
y: 5,
w: 5.5,
h: 6,
legend: {},
queries: [emptyQuery],
colors: DEFAULT_LINE_COLORS,
links: {self: ''}
}
]
},
],
links: {
self: '/cloudhub/v1/status/23/cells/c-bar-graphs-fly',
},
},
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'recent-alerts',
type: CellType.Alerts,
isWidget: true,
name: 'Alerts – Last 30 Days',
x: 0,
y: 5,
w: 6.5,
h: 6,
legend: {},
queries: [emptyQuery],
colors: DEFAULT_LINE_COLORS,
links: {self: ''},
},
// {
// ...NEW_DEFAULT_DASHBOARD_CELL,
// axes: emptyAxes,
// i: 'news-feed',
// type: CellType.News,
// isWidget: true,
// name: 'News Feed',
// x: 6.5,
// y: 5,
// w: 3,
// h: 6,
// legend: {},
// queries: [emptyQuery],
// colors: DEFAULT_LINE_COLORS,
// links: {self: ''},
// },
{
...NEW_DEFAULT_DASHBOARD_CELL,
axes: emptyAxes,
i: 'getting-started',
type: CellType.Guide,
isWidget: true,
name: 'Getting Started',
x: 6.5,
y: 5,
w: 5.5,
h: 6,
legend: {},
queries: [emptyQuery],
colors: DEFAULT_LINE_COLORS,
links: {self: ''},
},
]
}

0 comments on commit bdb290c

Please sign in to comment.