-
Notifications
You must be signed in to change notification settings - Fork 0
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
adds consumer / owner field to alerts created by rule registry #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import v4 from 'uuid/v4'; | |
import { Mutable } from 'utility-types'; | ||
import { AlertInstance } from '../../../../alerting/server'; | ||
import { ActionVariable, AlertInstanceState } from '../../../../alerting/common'; | ||
import { RuleParams, RuleType } from '../../types'; | ||
import { AlertAttributes, RuleParams, RuleType } from '../../types'; | ||
import { BaseRuleFieldMap, OutputOfFieldMap } from '../../../common'; | ||
import { PrepopulatedRuleEventFields } from '../create_scoped_rule_registry_client/types'; | ||
import { RuleRegistry } from '..'; | ||
|
@@ -68,6 +68,13 @@ export function createLifecycleRuleTypeFactory(): CreateLifecycleRuleType<BaseRu | |
rule, | ||
} = options; | ||
|
||
const so = await options.services.savedObjectsClient.get<AlertAttributes>( | ||
'alert', | ||
rule.uuid | ||
); | ||
|
||
console.error('RULE REGISTRY CONSUMER', so.attributes.consumer); | ||
Comment on lines
+71
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently the |
||
|
||
const decodedState = wrappedStateRt.decode(previousState); | ||
|
||
const state = isLeft(decodedState) | ||
|
@@ -169,7 +176,7 @@ export function createLifecycleRuleTypeFactory(): CreateLifecycleRuleType<BaseRu | |
'@timestamp': timestamp, | ||
'event.kind': 'state', | ||
'kibana.rac.alert.id': alertId, | ||
// 'owner': '' | ||
'kibana.rac.alert.owner': so.attributes.consumer, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding the consumer as the owner field on the alert here. |
||
}; | ||
|
||
const isNew = !state.trackedAlerts[alertId]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,27 @@ import { RuleRegistry } from './rule_registry'; | |
import { RacClient } from './rac_client/rac_client'; | ||
import { ScopedRuleRegistryClient } from './rule_registry/create_scoped_rule_registry_client/types'; | ||
import { BaseRuleFieldMap } from '../common'; | ||
import { SERVER_APP_ID } from '../../security_solution/server'; | ||
import { APM_SERVER_FEATURE_ID } from '../../apm/server'; | ||
|
||
export type RuleParams = Type<any>; | ||
|
||
export interface AlertAttributes<T extends RuleParams = RuleParams> { | ||
// actions: RuleAlertAction[]; | ||
consumer: string; | ||
enabled: boolean; | ||
name: string; | ||
tags: string[]; | ||
createdBy: string; | ||
createdAt: string; | ||
updatedBy: string; | ||
schedule: { | ||
interval: string; | ||
}; | ||
throttle: string; | ||
params: T; | ||
} | ||
Comment on lines
+26
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typing out the rule attributes from the saved object, used when querying for the rule SO to acquire the consumer. |
||
|
||
type TypeOfRuleParams<TRuleParams extends RuleParams> = TypeOf<TRuleParams>; | ||
|
||
type RuleExecutorServices< | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,7 @@ export const removeClashes = (doc: BaseSignalHit): BaseSignalHit => { | |
export const buildSignal = ( | ||
docs: BaseSignalHit[], | ||
rule: RulesSchema, | ||
owner: typeof SERVER_APP_ID | ||
owner: string // typeof SERVER_APP_ID | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. increasing scope of this type to |
||
): Signal => { | ||
const _meta = { | ||
version: SIGNALS_TEMPLATE_VERSION, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -227,6 +227,7 @@ export interface SignalHit { | |
|
||
export interface AlertAttributes<T extends RuleParams = RuleParams> { | ||
actions: RuleAlertAction[]; | ||
consumer: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exposing the consumer field from the rule SO attributes in the type here. |
||
enabled: boolean; | ||
name: string; | ||
tags: string[]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding owner to the alerts as data index mapping