Skip to content

Commit

Permalink
Merge branch 'main' into feature/1850-add-possibility-to-adjust-incid…
Browse files Browse the repository at this point in the history
…ents-mining-configuration
  • Loading branch information
shahargl authored Sep 14, 2024
2 parents d80eeef + 48d9826 commit 9443ac8
Show file tree
Hide file tree
Showing 35 changed files with 1,248 additions and 450 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ Workflow triggers can either be executed manually when an alert is activated or
<img width=32 height=32 src="https://github.com/keephq/keep/blob/main/keep-ui/public/icons/postgres-icon.png?raw=true"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img width=32 height=32 src="https://github.com/keephq/keep/blob/main/keep-ui/public/icons/snowflake-icon.png?raw=true"/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<img width=32 height=32 src="https://github.com/keephq/keep/blob/main/keep-ui/public/icons/clickhouse-icon.png?raw=true"/>
</p>
<h3 align="center">Communication platforms</h2>
<p align="center">
Expand Down
1 change: 1 addition & 0 deletions docs/mint.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"providers/documentation/axiom-provider",
"providers/documentation/azuremonitoring-provider",
"providers/documentation/centreon-provider",
"providers/documentation/clickhouse-provider",
"providers/documentation/cloudwatch-provider",
"providers/documentation/console-provider",
"providers/documentation/coralogix-provider",
Expand Down
29 changes: 29 additions & 0 deletions docs/providers/documentation/clickhouse-provider.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: 'ClickHouse'
sidebarTitle: 'ClickHouse Provider'
description: 'ClickHouse provider allows you to interact with ClickHouse database.'
---

## Overview

ClickHouse is an open-source column-oriented DBMS for online analytical processing that allows users to generate analytical reports using SQL queries in real-time.

## Authentication Parameters

The ClickHouse provider requires the following authentication parameters:

- `Clickhouse Username`: The username to authenticate with ClickHouse.
- `Clickhouse Password`: The password to authenticate with ClickHouse.
- `Clickhouse Hostname`: The host where ClickHouse is running.
- `Clickhouse Port`: The port where ClickHouse is running. The default port is `9000`.
- `Clickhouse Database`: The database to connect to.

## Connecting with the ClickHouse provider

1. Obtain the required authentication parameters.
2. Add ClickHouse provider to your keep account and configure with the above authentication parameters.

## Useful Links

- [ClickHouse](https://clickhouse.com/)
- [ClickHouse Statements](https://clickhouse.com/docs/en/sql-reference/statements/)
1 change: 1 addition & 0 deletions docs/workflows/syntax/basic-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ workflow:
workflow:
id: raw-sql-query
description: Monitor that time difference is no more than 1 hour
disabled: Optionally prevent this workflow from running
steps:
-
actions:
Expand Down
31 changes: 31 additions & 0 deletions examples/workflows/query_clickhouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
id: query-clickhouse
description: Query Clickhouse and send an alert if there is an error
triggers:
- type: manual

steps:
- name: clickhouse-step
provider:
config: "{{ providers.clickhouse }}"
type: clickhouse
with:
query: SELECT * FROM logs_table ORDER BY timestamp DESC LIMIT 1;
single_row: "True"

actions:
- name: ntfy-action
if: "'{{ steps.clickhouse-step.results.level }}' == 'ERROR'"
provider:
config: "{{ providers.ntfy }}"
type: ntfy
with:
message: "Error in clickhouse logs_table: {{ steps.clickhouse-step.results.level }}"
topic: clickhouse

- name: slack-action
if: "'{{ steps.clickhouse-step.results.level }}' == 'ERROR'"
provider:
config: "{{ providers.slack }}"
type: slack
with:
message: "Error in clickhouse logs_table: {{ steps.clickhouse-step.results.level }}"
35 changes: 33 additions & 2 deletions examples/workflows/query_victoriametrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@ workflow:
config: "{{ providers.victoriametrics }}"
type: victoriametrics
with:
query: process_memory_limit_bytes
query: avg(rate(process_cpu_seconds_total))
queryType: query
actions: []

actions:
- name: trigger-slack1
condition:
- name: threshold-condition
type: threshold
value: "{{ steps.victoriametrics-step.results.data.result.0.value.1 }}"
compare_to: 0.0050
alias: A
operator: ">"
provider:
type: slack
config: "{{ providers.slack }}"
with:
message: "Result: {{ steps.victoriametrics-step.results.data.result.0.value.1 }} is greater than 0.0040! 🚨"

- name: trigger-slack2
if: "{{ A }}"
provider:
type: slack
config: "{{ providers.slack }}"
with:
message: "Result: {{ steps.victoriametrics-step.results.data.result.0.value.1 }} is greater than 0.0040! 🚨"

- name: trigger-ntfy
if: "{{ A }}"
provider:
type: ntfy
config: "{{ providers.ntfy }}"
with:
message: "Result: {{ steps.victoriametrics-step.results.data.result.0.value.1 }} is greater than 0.0040! 🚨"
topic: ezhil
47 changes: 21 additions & 26 deletions keep-ui/app/workflows/[workflow_id]/executions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { useWorkflowRun } from "utils/hooks/useWorkflowRun";
import BuilderWorkflowTestRunModalContent from "../builder/builder-workflow-testrun-modal";
import Modal from "react-modal";
import { TableFilters } from "./table-filters";
import AlertTriggerModal from "../workflow-run-with-alert-modal";

const tabs = [
{ name: "All Time", value: 'alltime' },
Expand Down Expand Up @@ -67,10 +68,10 @@ export const FilterTabs = ({

export function StatsCard({ children, data }: { children: any, data?: string }) {
return <Card className="group relative container flex flex-col p-4 space-y-2 min-w-1/5">
{!!data && <div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 hidden group-hover:block bg-gray-800 text-white rounded py-1 p-2 text-2xl font-bold">
{data}
</div>}
{children}
{!!data && <div className="absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 hidden group-hover:block bg-gray-800 text-white rounded py-1 p-2 text-2xl font-bold">
{data}
</div>}
{children}
</Card>
}

Expand Down Expand Up @@ -109,11 +110,12 @@ export default function WorkflowDetailPage({
} = useWorkflowExecutionsV2(params.workflow_id, tab, executionPagination.limit, executionPagination.offset);

const {
loading,
runModalOpen,
setRunModalOpen,
runningWorkflowExecution,
setRunningWorkflowExecution } = useWorkflowRun(data?.workflow?.workflow_raw!)
isRunning,
handleRunClick,
getTriggerModalProps,
isRunButtonDisabled,
message,
} = useWorkflowRun(data?.workflow!)


if (isLoading || !data) return <Loading />;
Expand Down Expand Up @@ -144,7 +146,7 @@ export default function WorkflowDetailPage({
} else if (num >= 1_000) {
return `${(num / 1_000).toFixed(1)}k`;
} else {
return num.toString();
return num?.toString() ?? "";
}
};

Expand All @@ -159,7 +161,12 @@ export default function WorkflowDetailPage({
{/*TO DO update searchParams for these filters*/}
<FilterTabs tabs={tabs} setTab={setTab} tab={tab} />
</div>
<Button className="p-2 px-4" onClick={(e) => { e.preventDefault(); setRunModalOpen(true) }}>Run now</Button>
{!!data.workflow && <Button
disabled={isRunning || isRunButtonDisabled}
className="p-2 px-4"
onClick={(e: React.MouseEvent<HTMLButtonElement>) => { e.stopPropagation(); e.preventDefault(); handleRunClick?.(); }}
tooltip={message}
>Run now</Button>}
</div>
{data?.items && (
<div className="mt-2 flex flex-col gap-2">
Expand All @@ -170,16 +177,14 @@ export default function WorkflowDetailPage({
</Title>
<div>
<h1 className="text-2xl font-bold">{formatNumber(data.count ?? 0)}</h1>
{/* <div className="text-sm text-gray-500">__ from last month</div> */}
</div>
</StatsCard>
<StatsCard data= {`${data.passCount}/${data.failCount}`}>
<StatsCard data={`${data.passCount}/${data.failCount}`}>
<Title>
Pass / Fail ratio
</Title>
<div>
<h1 className="text-2xl font-bold">{formatNumber(data.passCount)}{'/'}{formatNumber(data.failCount)}</h1>
{/* <div className="text-sm text-gray-500">__ from last month</div> */}
</div>

</StatsCard>
Expand All @@ -189,7 +194,6 @@ export default function WorkflowDetailPage({
</Title>
<div>
<h1 className="text-2xl font-bold">{(data.count ? (data.passCount / data.count) * 100 : 0).toFixed(2)}{"%"}</h1>
{/* <div className="text-sm text-gray-500">__ from last month</div> */}
</div>

</StatsCard>
Expand All @@ -199,7 +203,6 @@ export default function WorkflowDetailPage({
</Title>
<div>
<h1 className="text-2xl font-bold">{(data.avgDuration ?? 0).toFixed(2)}</h1>
{/* <div className="text-sm text-gray-500">__ from last month</div> */}
</div>

</StatsCard>
Expand All @@ -221,16 +224,8 @@ export default function WorkflowDetailPage({
)}
</div>
</Card>
<Modal
isOpen={runModalOpen}
onRequestClose={() => { setRunModalOpen(false); setRunningWorkflowExecution(null) }}
className="bg-gray-50 p-4 md:p-10 mx-auto max-w-7xl mt-20 border border-orange-600/50 rounded-md"
>
<BuilderWorkflowTestRunModalContent
closeModal={() => { setRunModalOpen(false); setRunningWorkflowExecution(null) }}
workflowExecution={runningWorkflowExecution}
/>
</Modal>
{!!data.workflow && !!getTriggerModalProps && <AlertTriggerModal {...getTriggerModalProps()}
/>}
</>
);
}
2 changes: 1 addition & 1 deletion keep-ui/app/workflows/builder/builder-validators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function globalValidatorV2(

if (
!!definition?.properties &&
!definition.properties['manual'] &&
!definition.properties['manual'] &&
!definition.properties['interval'] &&
!definition.properties['alert']
) {
Expand Down
2 changes: 1 addition & 1 deletion keep-ui/app/workflows/builder/builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ function Builder({
triggers = { alert: { source: alertSource, name: alertName } };
}
setDefinition(
wrapDefinitionV2({...generateWorkflow(alertUuid, "", "", [], [], triggers), isValid: true})
wrapDefinitionV2({...generateWorkflow(alertUuid, "", "", false,[], [], triggers), isValid: true})
);
} else {
setDefinition(wrapDefinitionV2({...parseWorkflow(loadedAlertFile!, providers), isValid:true}));
Expand Down
Loading

0 comments on commit 9443ac8

Please sign in to comment.