Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
ddc69d1
PMM-10091 add changes from alerting poc
fabio-silva Jul 7, 2022
fbb2c7b
PMM-10091 fix tabs height
fabio-silva Jul 7, 2022
bc1e307
PMM-10091 fix highlight param
fabio-silva Jul 7, 2022
0fb1b2d
PMM-10091 fix table width break
fabio-silva Jul 7, 2022
68c8a13
Merge branch 'PMM-10089-grafana-9' into PMM-10091-g9-unified-alerting
fabio-silva Jul 20, 2022
9a66391
PMM-10344 add percona to rule types
fabio-silva Jul 20, 2022
2d11e77
PMM-10344 add templated alert to selection
fabio-silva Jul 20, 2022
82ba791
PMM-10344 first migration to react-hook-form
fabio-silva Jul 21, 2022
4aa20bf
PMM-10344 first working version
fabio-silva Jul 22, 2022
1b27cb7
PMM-10344 use grafana's Label
fabio-silva Jul 22, 2022
26c599d
PMM-10344 remove unused code
fabio-silva Jul 22, 2022
98c0842
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Jul 22, 2022
a7a580d
PMM-10344 add error messages
fabio-silva Jul 22, 2022
fab8f2d
PMM-10344 make templated alert rule default
fabio-silva Jul 22, 2022
8820976
PMM-10344 cleanup alerts code
fabio-silva Jul 23, 2022
650183f
PMM-10344 alert rule types on core
fabio-silva Jul 24, 2022
82290e4
PMM-10344 fix imports
fabio-silva Jul 25, 2022
64472a3
PMM-10344 fix getFloatDescription
fabio-silva Jul 25, 2022
297eedc
PMM-10344 add key to templates dropdown
fabio-silva Jul 25, 2022
d68f4ae
PMM-10344 check IA status
fabio-silva Jul 26, 2022
5810e9c
PMM-10344 fix tabs height
fabio-silva Jul 27, 2022
31fb9d4
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Jul 27, 2022
acab1cf
PMM-10344 link from templates to new rule
fabio-silva Jul 28, 2022
5922435
PMM-10344 use query params to select template
fabio-silva Jul 28, 2022
5ae44c6
PMM-10344 add loading status to select
fabio-silva Jul 28, 2022
b39d844
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 2, 2022
e2f00d0
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 9, 2022
6690cdf
PMM-10344 first version with alertmanager's api
fabio-silva Aug 11, 2022
b9638b9
PMM-10344 use actions to show/hide details
fabio-silva Aug 11, 2022
7c91203
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 15, 2022
cc1cbe0
PMM-10344 adapt test
fabio-silva Aug 15, 2022
de679dd
PMM-10344 send Alerting toggle out of tech preview
fabio-silva Aug 15, 2022
1ba511b
PMM-10344 remove notifs channels page
fabio-silva Aug 15, 2022
ee5f244
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 15, 2022
a2703bf
PMM-10344 fix alerting tests
fabio-silva Aug 15, 2022
1eeff47
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 15, 2022
27a3807
PMM-10344 remove useless backticks
fabio-silva Aug 16, 2022
ac755d9
PMM-10344 use receivers from store
fabio-silva Aug 16, 2022
f294fa2
PMM-10344 use redux to store rule templates
fabio-silva Aug 16, 2022
c34ab67
PMM-10344 remove moment from AlertRuleTemplate
fabio-silva Aug 16, 2022
e5f84e1
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 17, 2022
260c1a9
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 18, 2022
6a8f9c2
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 24, 2022
058b349
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 25, 2022
b3ec834
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 25, 2022
e031f50
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 30, 2022
14b0bd1
PMM-10344 fix date format
fabio-silva Aug 30, 2022
71a575e
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 30, 2022
f876da7
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Aug 30, 2022
1577040
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Sep 1, 2022
b407064
PMM-10344 change copy
fabio-silva Sep 1, 2022
4f3f9a6
PMM-10344 remove disabled field
fabio-silva Sep 1, 2022
603d296
PMM-10344 remove notification channels
fabio-silva Sep 1, 2022
7eb7053
PMM-10344 change filter fields
fabio-silva Sep 1, 2022
831f74c
PMM-10344 Allow group/folder selection
fabio-silva Sep 1, 2022
57e312b
PMM-10344 add @PERCONA annotations
fabio-silva Sep 1, 2022
9173303
PMM-10344 change API endpoint
fabio-silva Sep 1, 2022
71d5598
PMM-10344 set minimum duration
fabio-silva Sep 2, 2022
d079d8f
PMM-10344 "for" as string
fabio-silva Sep 3, 2022
00261ea
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Sep 3, 2022
c3c19fb
PMM-10344 fix double error toast
fabio-silva Sep 3, 2022
d11e81b
PMM-10344 change duration label
fabio-silva Sep 5, 2022
3229675
PMM-10344 send duration always as seconds
fabio-silva Sep 5, 2022
1c217e0
PMM-10344 hide communication settings
fabio-silva Sep 6, 2022
70e18dd
PMM-10344 remove alerting item if off
fabio-silva Sep 6, 2022
f3fc91b
PMM-10344 use default name
fabio-silva Sep 6, 2022
a59da28
PMM-10344 set default group
fabio-silva Sep 7, 2022
171c938
PMM-10344 break word in rules table
fabio-silva Sep 8, 2022
5385806
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Sep 8, 2022
22bb100
Merge branch 'PMM-10089-grafana-9' into PMM-10344-g9-unified-alerting
fabio-silva Sep 8, 2022
b67a2c9
PMM-10344 fix double tabs
fabio-silva Sep 9, 2022
a95db75
PMM-10344 fix bad import in test
fabio-silva Sep 9, 2022
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 packages/grafana-data/src/types/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ abstract class DataSourceApi<
* Defines new variable support
* @alpha -- experimental
*/
// @ts-ignore
variables?:
| StandardVariableSupport<DataSourceApi<TQuery, TOptions>>
| CustomVariableSupport<DataSourceApi<TQuery, TOptions>>
Expand Down
3 changes: 2 additions & 1 deletion packages/grafana-ui/src/components/Tabs/TabsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const getTabsBarStyles = stylesFactory((theme: GrafanaTheme2, hideBorder = false
tabs: css`
position: relative;
display: flex;
height: ${theme.components.menuTabs.height}px;
${!!vertical ? 'height' : 'min-height'}: ${theme.components.menuTabs.height}px;
flex-direction: ${!!vertical ? 'column' : 'row'};
flex-wrap: ${!!vertical ? 'no-wrap' : 'wrap'};
`,
};
});
Expand Down
16 changes: 7 additions & 9 deletions public/app/core/components/NavBar/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { NavBarToggle } from './NavBarToggle';
import {
getPmmSettingsPage,
PMM_ADD_INSTANCE_PAGE,
PMM_ALERTING_PAGE,
PMM_BACKUP_PAGE,
PMM_DBAAS_PAGE,
PMM_ENTITLEMENTS_PAGE,
Expand All @@ -46,6 +45,7 @@ import {
getActiveItem,
isMatchOrInnerMatch,
isSearchActive,
removeAlertingMenuItem,
SEARCH_ITEM_ID,
} from './utils';

Expand All @@ -62,7 +62,7 @@ export const NavBar = React.memo(() => {
const dispatch = useDispatch();
const kiosk = getKioskMode();
const { result } = useSelector(getPerconaSettings);
const { alertingEnabled } = result!;
const { alertingEnabled, sttEnabled, dbaasEnabled, backupEnabled } = result!;
const { isPlatformUser, isAuthorized } = useSelector(getPerconaUser);
const [showSwitcherModal, setShowSwitcherModal] = useState(false);
const [menuOpen, setMenuOpen] = useState(false);
Expand Down Expand Up @@ -114,11 +114,11 @@ export const NavBar = React.memo(() => {
.map((item) => enrichWithClickDispatch(item, dispatch, dispatchOffset));

const activeItem = isSearchActive(location) ? searchItem : getActiveItem(navTree, location.pathname);
const iaMenuItem = alertingEnabled ? buildIntegratedAlertingMenuItem(coreItems) : removeAlertingMenuItem(coreItems);

// @PERCONA
// All these dispatches are our pages
dispatch(updateNavIndex(getPmmSettingsPage(alertingEnabled)));
dispatch(updateNavIndex(PMM_ALERTING_PAGE));
dispatch(updateNavIndex(PMM_STT_PAGE));
dispatch(updateNavIndex(PMM_DBAAS_PAGE));
dispatch(updateNavIndex(PMM_BACKUP_PAGE));
Expand All @@ -128,12 +128,14 @@ export const NavBar = React.memo(() => {
dispatch(updateNavIndex(PMM_ENTITLEMENTS_PAGE));
dispatch(updateNavIndex(PMM_ENVIRONMENT_OVERVIEW_PAGE));

if (iaMenuItem) {
dispatch(updateNavIndex(iaMenuItem));
}

// @PERCONA
useEffect(() => {
const updatedNavTree = cloneDeep(initialState);

const { sttEnabled, alertingEnabled, dbaasEnabled, backupEnabled } = result!;

// @PERCONA
if (isPlatformUser) {
updatedNavTree.push(PMM_ENTITLEMENTS_PAGE);
Expand All @@ -145,10 +147,6 @@ export const NavBar = React.memo(() => {
if (isAuthorized) {
buildInventoryAndSettings(updatedNavTree);

if (alertingEnabled) {
buildIntegratedAlertingMenuItem(updatedNavTree);
}

if (sttEnabled) {
updatedNavTree.push(PMM_STT_PAGE);
}
Expand Down
65 changes: 22 additions & 43 deletions public/app/core/components/NavBar/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,42 +100,20 @@ export const PMM_BACKUP_PAGE: NavModelItem = {
],
};

export const PMM_ALERTING_PAGE: NavModelItem = {
id: 'integrated-alerting',
icon: 'bell',
text: 'Integrated Alerting',
url: `${config.appSubUrl}/integrated-alerting`,
subTitle: 'Percona Integrated Alerting',
section: NavSection.Core,
breadcrumbs: [
{
title: 'Integrated Alerting',
url: `${config.appSubUrl}/integrated-alerting`,
},
],
children: [
{
id: 'integrated-alerting-alerts',
text: 'Alerts',
url: `${config.appSubUrl}/integrated-alerting/alerts`,
},
{
id: 'integrated-alerting-rules',
text: 'Alert Rules',
url: `${config.appSubUrl}/integrated-alerting/alert-rules`,
},
{
id: 'integrated-alerting-templates',
text: 'Alert Rule Templates',
url: `${config.appSubUrl}/integrated-alerting/alert-rule-templates`,
},
{
id: 'integrated-alerting-notification-channels',
text: 'Notification Channels',
url: `${config.appSubUrl}/integrated-alerting/notification-channels`,
},
],
};
export const PMM_ALERTING_PERCONA_ALERTS: NavModelItem[] = [
{
id: 'integrated-alerting-alerts',
text: 'Fired alerts',
icon: 'info-circle',
url: `${config.appSubUrl}/alerting/alerts`,
},
{
id: 'integrated-alerting-templates',
text: 'Alert rule templates',
icon: 'brackets-curly',
url: `${config.appSubUrl}/alerting/alert-rule-templates`,
},
];

export const PMM_INVENTORY_PAGE: NavModelItem = {
id: 'inventory',
Expand Down Expand Up @@ -210,13 +188,14 @@ export const getPmmSettingsPage = (alertingEnabled = false): NavModelItem => {
},
];

if (alertingEnabled) {
children.push({
id: 'settings-communication',
text: 'Communication',
url: `${config.appSubUrl}/settings/communication`,
});
}
// TODO remove after integrating SMTP/slack with Grafana's alerting system
// if (alertingEnabled) {
// children.push({
// id: 'settings-communication',
// text: 'Communication',
// url: `${config.appSubUrl}/settings/communication`,
// });
// }
const page: NavModelItem = {
id: 'settings',
icon: 'percona-setting',
Expand Down
45 changes: 24 additions & 21 deletions public/app/core/components/NavBar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import appEvents from '../../app_events';
import { getFooterLinks } from '../Footer/Footer';
import { HelpModal } from '../help/HelpModal';

import { PMM_ADD_INSTANCE_PAGE } from './constants';
import { PMM_ADD_INSTANCE_PAGE, PMM_ALERTING_PERCONA_ALERTS } from './constants';

export const SEARCH_ITEM_ID = 'search';
export const NAV_MENU_PORTAL_CONTAINER_ID = 'navbar-menu-portal-container';
Expand Down Expand Up @@ -199,30 +199,33 @@ export function getNavModelItemKey(item: NavModelItem) {
return item.id ?? item.text;
}

export const buildIntegratedAlertingMenuItem = (mainLinks: NavModelItem[]): NavModelItem[] => {
const integratedAlertingLink = {
id: 'integrated-alerting',
text: 'Integrated Alerting',
icon: 'bell',
url: `${config.appSubUrl}/integrated-alerting`,
};
export const buildIntegratedAlertingMenuItem = (mainLinks: NavModelItem[]): NavModelItem | undefined => {
const alertingItem = mainLinks.find(({ id }) => id === 'alerting');

const alertingIndex = mainLinks.findIndex(({ id }) => id === 'alerting');
if (alertingItem?.url) {
alertingItem.url = `${config.appSubUrl}/alerting/alerts`;
}

if (alertingIndex === -1) {
mainLinks.push({
id: 'alerting',
text: 'Alerting',
icon: 'bell',
url: `${config.appSubUrl}/integrated-alerting/alerts`,
subTitle: 'Alert rules & notifications',
children: [integratedAlertingLink],
});
} else {
mainLinks[alertingIndex].children?.unshift(integratedAlertingLink, DIVIDER);
alertingItem?.children?.unshift(...PMM_ALERTING_PERCONA_ALERTS);
return alertingItem;
};

export const removeAlertingMenuItem = (mainLinks: NavModelItem[]) => {
const alertingItem = mainLinks.find(({ id }) => id === 'alerting');

PMM_ALERTING_PERCONA_ALERTS.forEach((alertingTab, idx) => {
const item = alertingItem?.children?.find((c) => c.id === alertingTab.id);

if (item) {
alertingItem?.children?.splice(idx, 1);
}
});

if (alertingItem?.url) {
alertingItem.url = `${config.appSubUrl}/alerting/list`;
}

return mainLinks;
return alertingItem;
};

export const buildInventoryAndSettings = (mainLinks: NavModelItem[]): NavModelItem[] => {
Expand Down
20 changes: 15 additions & 5 deletions public/app/core/components/Select/FolderPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import appEvents from '../../app_events';
export type FolderPickerFilter = (hits: DashboardSearchHit[]) => DashboardSearchHit[];

export interface Props {
onChange: ($folder: { title: string; id: number }) => void;
// @PERCONA
// Added uid here
onChange: ($folder: { title: string; id: number; uid: number }) => void;
enableCreateNew?: boolean;
rootName?: string;
enableReset?: boolean;
Expand Down Expand Up @@ -137,7 +139,9 @@ export class FolderPicker extends PureComponent<Props, State> {
{
folder: newFolder,
},
() => this.props.onChange({ id: newFolder.value!, title: newFolder.label! })
// @PERCONA
// Added uid here
() => this.props.onChange({ id: newFolder.value!, title: newFolder.label!, uid: newFolder.uid })
);
};

Expand All @@ -147,7 +151,9 @@ export class FolderPicker extends PureComponent<Props, State> {

if (newFolder.id > -1) {
appEvents.emit(AppEvents.alertSuccess, ['Folder Created', 'OK']);
folder = { value: newFolder.id, label: newFolder.title };
// @PERCONA
// Added uid here
folder = { value: newFolder.id, label: newFolder.title, uid: newFolder.uid };
this.setState(
{
folder: newFolder,
Expand Down Expand Up @@ -201,7 +207,9 @@ export class FolderPicker extends PureComponent<Props, State> {
() => {
// if this is not the same as our initial value notify parent
if (folder && folder.value !== initialFolderId) {
this.props.onChange({ id: folder.value!, title: folder.label! });
// @PERCONA
// Added uid here
this.props.onChange({ id: folder.value!, title: folder.label!, uid: folder.uid });
}
}
);
Expand Down Expand Up @@ -234,7 +242,9 @@ export class FolderPicker extends PureComponent<Props, State> {

function mapSearchHitsToOptions(hits: DashboardSearchHit[], filter?: FolderPickerFilter) {
const filteredHits = filter ? filter(hits) : hits;
return filteredHits.map((hit) => ({ label: hit.title, value: hit.id }));
// @PERCONA
// Added uid here
return filteredHits.map((hit) => ({ label: hit.title, value: hit.id, uid: hit.uid }));
}

interface Args {
Expand Down
25 changes: 13 additions & 12 deletions public/app/core/reducers/navModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,21 @@ export const navIndexReducer = (state: NavIndex = initialState, action: AnyActio
if (updateNavIndex.match(action)) {
const newPages: NavIndex = {};
const payload = action.payload;

if (payload.children && payload.children.length) {
for (const node of payload.children) {
if (node.id) {
newPages[node.id] = {
...node,
parentItem: payload,
};
if (payload) {
if (payload.children && payload.children.length) {
for (const node of payload.children) {
if (node.id) {
newPages[node.id] = {
...node,
parentItem: payload,
};
}
}
} else if (payload.id) {
newPages[payload.id] = {
...payload,
};
}
} else if (payload.id) {
newPages[payload.id] = {
...payload,
};
}

return { ...state, ...newPages };
Expand Down
2 changes: 1 addition & 1 deletion public/app/features/alerting/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const commonRoutes: RouteDescriptor[] = [
{
path: '/alerting',
// eslint-disable-next-line react/display-name
component: () => <Redirect to="/alerting/list" />,
component: () => <Redirect to="/alerting/alerts" />,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ const getStyles = <T extends unknown>(
`,
bodyCell: css`
overflow: hidden;
// @PERCONA
word-break: break-all;

${theme.breakpoints.down('sm')} {
grid-column-end: right;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { css } from '@emotion/css';
import React, { FC, useMemo, useState } from 'react';
import { FormProvider, useForm, UseFormWatch } from 'react-hook-form';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { Link } from 'react-router-dom';

import { GrafanaTheme2 } from '@grafana/data';
import { Button, ConfirmModal, CustomScrollbar, PageToolbar, Spinner, useStyles2 } from '@grafana/ui';
import { useAppNotification } from 'app/core/copy/appNotification';
import { useCleanup } from 'app/core/hooks/useCleanup';
import { useQueryParams } from 'app/core/hooks/useQueryParams';
import { getPerconaSettings } from 'app/percona/shared/core/selectors';
import { RuleWithLocation } from 'app/types/unified-alerting';

import { useUnifiedAlertingSelector } from '../../hooks/useUnifiedAlertingSelector';
Expand All @@ -23,6 +24,7 @@ import { DetailsStep } from './DetailsStep';
import { GrafanaEvaluationBehavior } from './GrafanaEvaluationBehavior';
import { NotificationsStep } from './NotificationsStep';
import { RuleInspector } from './RuleInspector';
import { TemplateStep } from './TemplateStep/TemplateStep';
import { QueryAndAlertConditionStep } from './query-and-alert-condition/QueryAndAlertConditionStep';

type Props = {
Expand All @@ -35,6 +37,7 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
const notifyApp = useAppNotification();
const [queryParams] = useQueryParams();
const [showEditYaml, setShowEditYaml] = useState(false);
const { result } = useSelector(getPerconaSettings);

const returnTo: string = (queryParams['returnTo'] as string | undefined) ?? '/alerting/list';
const [showDeleteModal, setShowDeleteModal] = useState<boolean>(false);
Expand All @@ -47,9 +50,12 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
...getDefaultFormValues(),
queries: getDefaultQueries(),
...(queryParams['defaults'] ? JSON.parse(queryParams['defaults'] as string) : {}),
type: RuleFormType.grafana,
// @PERCONA
// Set templated as default
type: result && !!result.alertingEnabled ? RuleFormType.templated : RuleFormType.grafana,
group: result && !!result.alertingEnabled ? 'default-alert-group' : '',
};
}, [existing, queryParams]);
}, [existing, queryParams, result]);

const formAPI = useForm<RuleFormValues>({
mode: 'onSubmit',
Expand All @@ -63,6 +69,7 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
const dataSourceName = watch('dataSourceName');

const showStep2 = Boolean(type && (type === RuleFormType.grafana || !!dataSourceName));
const showTemplateStep = type === RuleFormType.templated;

const submitState = useUnifiedAlertingSelector((state) => state.ruleForm.saveRule) || initialAsyncRequestState;
useCleanup((state) => state.unifiedAlerting.ruleForm.saveRule);
Expand Down Expand Up @@ -152,6 +159,8 @@ export const AlertRuleForm: FC<Props> = ({ existing }) => {
<CustomScrollbar autoHeightMin="100%" hideHorizontalTrack={true}>
<div className={styles.contentInner}>
<QueryAndAlertConditionStep editingExistingRule={!!existing} />
{/* @PERCONA */}
{showTemplateStep && <TemplateStep />}
{showStep2 && (
<>
{type === RuleFormType.grafana ? <GrafanaEvaluationBehavior /> : <CloudEvaluationBehavior />}
Expand Down
Loading