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

Change alert definition meta #217

Merged
merged 1 commit into from
Jan 21, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def extract_event_data(event)
#
# {
# "annotations": {
# "message": "Node ocp-compute01.10.35.48.236.nip.io is down",
# "severity": "HIGH",
# "description": "Node ocp-compute01.10.35.48.236.nip.io is down",
# "source": "ManageIQ",
# "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
# },
# "endsAt": "0001-01-01T00:00:00Z",
# "generatorURL": "http://prometheus-4018548653-w3str:9090/graph?g0.expr=container_fs_usage_bytes%7Bcontainer_name%3D%22%22%2Cdevice%3D%22%2Fdev%2Fmapper%2Fvg0-lv_root%22%7D+%3E+4e%2B07&g0.tab=0",
# "labels": {
# "severity": "error",
# "alertname": "Node down",
# "beta_kubernetes_io_arch": "amd64",
# "beta_kubernetes_io_os": "linux",
Expand All @@ -76,17 +76,18 @@ def extract_event_data(event)
event = event.dup

annotations = event["annotations"]
event[:url] = annotations["url"]
event[:severity] = parse_severity(annotations["severity"])
labels = event["labels"]

event[:url] = annotations["url"]
event[:severity] = parse_severity(labels["severity"])
# TODO(mtayer): remove after https://github.com/ManageIQ/manageiq/pull/16339
event[:ems_ref] = incident_identifier(labels, annotations, event["startsAt"])
event[:resolved] = event["status"] == "resolved"
{
:source => "DATAWAREHOUSE",
:timestamp => Time.zone.now,
:event_type => "datawarehouse_alert",
:message => annotations["message"],
:message => annotations["description"],

Choose a reason for hiding this comment

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

We're settling on a convention where 'summary' is the short string (general data) and 'description' is the more verbose, detailed string (with specific data). For example:

alert: DockerLatencyHigh
expr: round(max(kubelet_docker_operations_latency_microseconds{quantile="0.9"})
  BY (instance) / 1e+06, 0.1) > 1
for: 5m
labels:
  severity: warning
annotations:
  summary: Docker latency is high
  description: Docker latency is {{ $value }} seconds for 90% of kubelet operations

As an operator, the more compact 'summary' is what I would want displayed inline, expanding to display 'description' if I want more details.

Copy link
Author

@moolitayer moolitayer Jan 18, 2018

Choose a reason for hiding this comment

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

Right now the screen is designed to have only one type of message.
And although we persist both we pass only the long name to the alert and show in the screen.

Would you like to open a bug for this to change?

:ems_ref => incident_identifier(labels, annotations, event["startsAt"]),
:full_data => event.to_h
}.merge(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,30 @@ def initialize(ems)
let(:node_annotations) { {"miqTarget" => 'ContainerNode'} }
let(:ext_annotations) { {"miqTarget" => 'ExtManagementSystem'} }

context "#extract_event_data" do
it "extracts severity based on the severity label" do
expect(subject).to receive(:parse_severity).with("info").and_call_original
expect(
subject.extract_event_data(
"labels" => {"severity" => "info"},
"annotations" => {"severity" => "ignoreme"},
)[:full_data]
).to include(:severity => "info")
end

it "extracts messaged based on the description annotation" do
expect(
subject.extract_event_data(
"annotations" => {
"description" => "important",
"message" => "ignoreme",
},
"labels" => {},
)
).to include(:message => "important")
end
end

context "#find_target" do
it "binds to container node by default" do
target = FactoryGirl.create(:container_node, :name => 'testing')
Expand Down