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

Use cards #2

Merged
merged 21 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
bug hunt
  • Loading branch information
johntdyer committed Nov 22, 2019
commit 53f75beb9e819c4b50c9a9159b5e752a6245be3d
258 changes: 103 additions & 155 deletions contrib/example-ok.json
Original file line number Diff line number Diff line change
@@ -1,162 +1,110 @@
{
"timestamp": 1522170515,

"entity": {
"entity_class": "agent",
"system": {
"hostname": "webserver01",
"os": "linux",
"platform": "centos",
"platform_family": "rhel",
"platform_version": "7.4.1708",
"network": {
"interfaces": [{
"name": "lo",
"addresses": [
"127.0.0.1/8",
"::1/128"
]
},
{
"name": "enp0s3",
"mac": "08:00:27:11:ad:d2",
"addresses": [
"10.0.2.15/24",
"fe80::26a5:54ec:cf0d:9704/64"
]
},
{
"name": "enp0s8",
"mac": "08:00:27:bc:be:60",
"addresses": [
"172.28.128.3/24",
"fe80::a00:27ff:febc:be60/64"
]
}
]
},
"arch": "amd64"
},
"subscriptions": [
"testing",
"entity:webserver01"
],
"last_seen": 1542667635,
"deregister": false,
"deregistration": {},
"user": "agent",
"redact": [
"password",
"passwd",
"pass",
"api_key",
"api_token",
"access_key",
"secret_key",
"private_key",
"secret"
],
"metadata": {
"name": "webserver01",
"namespace": "default",
"labels": null,
"annotations": null
}
"type": "Event",
"api_version": "core/v2",
"metadata": {
"namespace": "default"
},
"check": {
"check_hooks": null,
"duration": 1.903135228,
"executed": 1522100915,
"high_flap_threshold": 0,
"history": [{
"executed": 1522100315
},
{
"executed": 1522100915
}
],
"command": "http_check.sh http://localhost:80",
"handlers": [
"webex-teams"
],
"high_flap_threshold": 0,
"interval": 20,
"low_flap_threshold": 0,
"publish": true,
"runtime_assets": [],
"subscriptions": [
"testing"
],
"proxy_entity_name": "",
"check_hooks": null,
"stdin": false,
"ttl": 0,
"timeout": 0,
"duration": 0.010849143,
"executed": 1542667666,
"history": [
{
"status": 1,
"executed": 1542667666
},
{
"status": 0,
"executed": 1522100915
},
{
"status": 0,
"executed": 1522300915
},
{
"status": 0,
"executed": 1522100915
"spec": {
"check": {
"check_hooks": null,
"command": "check-cpu.sh -w 75 -c 90",
"duration": 1.07055808,
"env_vars": null,
"executed": 1552594757,
"handlers": [],
"high_flap_threshold": 0,
"history": [{
"executed": 1552594757,
"status": 0
}],
"interval": 60,
"issued": 1552594757,
"last_ok": 1552594758,
"low_flap_threshold": 0,
"metadata": {
"name": "check-cpu",
"namespace": "default"
},
{
"status": 0,
"executed": 1522300915
},
{
"status": 0,
"executed": 1522200915
},
{
"status": 0,
"executed": 1522300915
},
{
"status": 0,
"executed": 1522400915
},
{
"status": 1,
"executed": 1522500915
"occurrences": 1,
"occurrences_watermark": 1,
"output": "CPU OK - Usage:3.96\n",
"output_metric_format": "",
"output_metric_handlers": [],
"proxy_entity_name": "",
"publish": true,
"round_robin": false,
"runtime_assets": [],
"state": "passing",
"status": 0,
"stdin": false,
"subdue": null,
"subscriptions": [
"linux"
],
"timeout": 0,
"total_state_change": 0,
"ttl": 0
},
"entity": {
"deregister": false,
"deregistration": {},
"entity_class": "agent",
"last_seen": 1552594641,
"metadata": {
"name": "sensu-centos",
"namespace": "default"
},
{
"status": 0,
"executed": 1522600915
"redact": [
"password",
"passwd",
"pass",
"api_key",
"api_token",
"access_key",
"secret_key",
"private_key",
"secret"
],
"subscriptions": [
"linux",
"entity:sensu-centos"
],
"system": {
"arch": "amd64",
"hostname": "sensu-centos",
"network": {
"interfaces": [{
"addresses": [
"127.0.0.1/8",
"::1/128"
],
"name": "lo"
},
{
"addresses": [
"10.0.2.15/24",
"fe80::9688:67ca:3d78:ced9/64"
],
"mac": "08:00:27:11:ad:d2",
"name": "enp0s3"
},
{
"addresses": [
"172.28.128.3/24",
"fe80::a00:27ff:fe6b:c1e9/64"
],
"mac": "08:00:27:6b:c1:e9",
"name": "enp0s8"
}
]
},
"os": "linux",
"platform": "centos",
"platform_family": "rhel",
"platform_version": "7.4.1708"
},
{
"status": 0,
"executed": 1522700915
}

],
"issued": 1542667666,
"output": "ok",
"state": "ok",
"status": 0,
"total_state_change": 0,
"last_ok": 0,
"occurrences": 0,
"occurrences_watermark": 1,
"output_metric_format": "",
"output_metric_handlers": [],
"env_vars": null,
"metadata": {
"name": "check-nginx",
"namespace": "default",
"labels": null,
"annotations": null
}
"user": "agent"
},
"timestamp": 1552594758
}
}
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ func getTemplateNew(event *corev2.Event) string {

func sendMessage(event *corev2.Event) error {
client := resty.New()

validateEvent(event)

template := getTemplateNew(event)

client.
Expand Down
5 changes: 3 additions & 2 deletions template.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ const inccidentTemplate = `{
"width": "stretch",
"items": [{
"type": "FactSet",
"facts": [{
"facts": [
{
"title": "**Entity:** ",
"value": "[{{.EntityName}}](foo)"
}
Expand Down Expand Up @@ -130,7 +131,7 @@ const inccidentTemplate = `{
}]
}]
}
{{end}}
{{end}}
]
}
}
Expand Down