Skip to content
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

feat: Enable metric alerts on dev #140

Merged
merged 2 commits into from
Dec 6, 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
5 changes: 5 additions & 0 deletions .changeset/healthy-elephants-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hyperdx/app': patch
---

Allow to set alerts for metric charts on development env
42 changes: 21 additions & 21 deletions packages/app/src/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,28 @@ export const SlackChannelForm = ({

return (
<>
{hasSlackWebhooks && (
<div className="mt-3">
<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled>
Select a Slack Webhook
<div className="mt-3">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

always showing this select to ensure required arg will prevent form from submitting. we can also improve UX and migrate to react-hook-forms later

<Form.Label className="text-muted">Slack Webhook</Form.Label>
<Form.Select
className="bg-black border-0 mb-1 px-3"
required
id="webhookId"
size="sm"
{...webhookSelectProps}
>
{/* Ensure user selects a slack webhook before submitting form */}
<option value="" disabled selected>
{hasSlackWebhooks
? 'Select a Slack Webhook'
: 'No Slack Webhooks available'}
</option>
{slackWebhooks?.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
{slackWebhooks.data.map((sw: any) => (
<option key={sw._id} value={sw._id}>
{sw.name}
</option>
))}
</Form.Select>
</div>
)}
))}
</Form.Select>
</div>

<div className="mb-2">
<a
Expand Down
6 changes: 5 additions & 1 deletion packages/app/src/EditChartForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import EditChartFormAlerts from './EditChartFormAlerts';
import HDXNumberChart from './HDXNumberChart';
import HDXTableChart from './HDXTableChart';
import { intervalToGranularity } from './Alert';
import { METRIC_ALERTS_ENABLED } from './config';

export type Chart = {
id: string;
Expand Down Expand Up @@ -867,6 +868,9 @@ export const EditLineChartForm = ({
return null;
}

const isChartAlertsFeatureEnabled =
editedChart.series[0].table === 'logs' || METRIC_ALERTS_ENABLED;

return (
<form
onSubmit={e => {
Expand Down Expand Up @@ -970,7 +974,7 @@ export const EditLineChartForm = ({
}}
/>

{editedChart.series[0].table === 'logs' && (
{isChartAlertsFeatureEnabled && (
<div className="mt-4 border-top border-bottom border-grey p-2 py-3">
{isLocalDashboard ? (
<span className="text-gray-600 fs-8">
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/TeamPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ export default function TeamPage() {
name="name"
placeholder="My Slack Webhook"
className="border-0 mb-4 px-3"
required
/>
<Form.Label className="text-start text-muted fs-7 mb-2 mt-2">
Webhook URL
Expand All @@ -351,6 +352,7 @@ export default function TeamPage() {
name="url"
placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX"
className="border-0 mb-4 px-3"
required
/>
<Button
variant="brand-primary"
Expand Down
3 changes: 3 additions & 0 deletions packages/app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const HDX_COLLECTOR_URL =
'http://localhost:4318';

export const IS_OSS = process.env.NEXT_PUBLIC_IS_OSS ?? 'true' === 'true';

// Features in development
export const METRIC_ALERTS_ENABLED = process.env.NODE_ENV === 'development';
Loading