Skip to content

feat: make endpoint report the upstream status code #5510

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

Merged
merged 19 commits into from
Nov 27, 2024
Merged
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
26 changes: 13 additions & 13 deletions libflux/go/libflux/buildinfo.gen.go
Original file line number Diff line number Diff line change
@@ -80,27 +80,27 @@ var sourceHashes = map[string]string{
"stdlib/contrib/anaisdg/anomalydetection/mad_test.flux": "ef886757f79114d8b6785f5a3ef718c83cfd020946b10e4ec0c351cdf4153293",
"stdlib/contrib/anaisdg/statsmodels/linearreg.flux": "1e2f62eedbf59b5b66bf3e79f85e86b5f3448b042a3bc2bb0441b327ff5b179a",
"stdlib/contrib/anaisdg/statsmodels/linearreg_test.flux": "205a5cb33a5d30d524b4e64374e1c7d5fc711a174a7fd5fee82c331acfd5dbb3",
"stdlib/contrib/bonitoo-io/alerta/alerta.flux": "a3fe3d4bc1bddf92e1b3e3a1e9e013ea035a1c32d0f27facad2d9f8f93b6a891",
"stdlib/contrib/bonitoo-io/alerta/alerta.flux": "fc56e7119786d4ee83e6a7e1750ff21eaeca2a68ef64f6086e917ba6c890e2c4",
"stdlib/contrib/bonitoo-io/hex/hex.flux": "91b6bfacef57d976b869b523a3290037d7593a60fba8280d10440e2d979ca0fd",
"stdlib/contrib/bonitoo-io/servicenow/servicenow.flux": "4102a2b4bc93113f86ccfa2e1615edd14c26fcc557f60c2c5c881cf67fc1f187",
"stdlib/contrib/bonitoo-io/servicenow/servicenow.flux": "5c296c443415fe34d9c20cd217ee631774150181ff9ed012e45aad778b7d2297",
"stdlib/contrib/bonitoo-io/tickscript/alert_test.flux": "15998cce72093e6a58a23ca2194275c693ddbb832e10a0cdcfbdf49d492723ab",
"stdlib/contrib/bonitoo-io/tickscript/alert_with_topic_test.flux": "947e56b091c7f2cfce493025c005770827395985edd34546d6d1846db9dcdde0",
"stdlib/contrib/bonitoo-io/tickscript/deadman_empty_test.flux": "4f4f015ec515f5f335d14e2a136d422c9e6cd343b01a22bb1e0ed69ae5a840b4",
"stdlib/contrib/bonitoo-io/tickscript/deadman_threshold_test.flux": "a0f378277b02d8d3bc4c5a4ff27290c21cef433573598c2382faf0ee5b8e5b97",
"stdlib/contrib/bonitoo-io/tickscript/tickscript.flux": "ca93b020441699fcf74102a024a9bf31603ee67dd9cf01730b18f199beff5ab4",
"stdlib/contrib/bonitoo-io/victorops/victorops.flux": "44d6674a86ceff7995153deca38db142fc0422b5a3526f5d0263a761d222269f",
"stdlib/contrib/bonitoo-io/zenoss/zenoss.flux": "8f6de802b3176bf2524018e32ec5dc4eddd66db86abdeec837e9ca65ad7cc863",
"stdlib/contrib/chobbs/discord/discord.flux": "339d0d91ab323265fe5cbbf63b7278375992fefe46fbe6c9a302c5b37f36e8ec",
"stdlib/contrib/bonitoo-io/victorops/victorops.flux": "c98fcd6ec34aedbaa1ce9b2cfcc84aebb78239399c4ff59dfe92fde4cc13de7b",
"stdlib/contrib/bonitoo-io/zenoss/zenoss.flux": "d77550c76070481453d74c7cf5d091a5029f9c75632add62f1cc281cc1b1fb6a",
"stdlib/contrib/chobbs/discord/discord.flux": "52d3980adc42eeff68e84a89bc80fd4e558797b421197c87d145b092e2320064",
"stdlib/contrib/jsternberg/influxdb/influxdb.flux": "afc52f2e31d5e063e318b752d077c58189317c373494563ea0895cdcdea49074",
"stdlib/contrib/qxip/clickhouse/clickhouse.flux": "8ad86d9c3c7a4271178d5e2fa9bb850856363cf470d92c3f5010b6de9e770db1",
"stdlib/contrib/qxip/hash/hash.flux": "496d0ae212408a44f442bb5093fa92691d3f72927618ee1e841b52646db126c4",
"stdlib/contrib/qxip/logql/logql.flux": "f855e5a58efd4332c63bbdbb41efc9522c97722c44202f4b26c5226c89e7a646",
"stdlib/contrib/rhajek/bigpanda/bigpanda.flux": "0f4d43a7ae08f0ce5e00a746082dbdae06008bcd69cb00b52f0b4f1bb10b7323",
"stdlib/contrib/sranka/opsgenie/opsgenie.flux": "5313b78a30ffb01c606397c9bea954bdd4ca06c44663268bab1e0f706fc6d2c5",
"stdlib/contrib/rhajek/bigpanda/bigpanda.flux": "8cf2760346884a949962fb5d1f89cb16f0ef127e245f6e492f6a2a71630efc64",
"stdlib/contrib/sranka/opsgenie/opsgenie.flux": "bd16a94df7c9e005b0cfe78ab9eb03d7b8777458415b87ac3b64f3a3594fed4c",
"stdlib/contrib/sranka/sensu/sensu.flux": "c3aff3caa234f7f1991f0d37cc40abaee7ad493fbcd7914a0009ac7d66ce0325",
"stdlib/contrib/sranka/teams/teams.flux": "954fb12da5de2bde81ecd047a2c1b3bf05256360cd3515dc7522ca89876996bd",
"stdlib/contrib/sranka/telegram/telegram.flux": "0affc082fbcba7aef7b9ef9a2549812419d922231c0d6524bbfed6e451d05516",
"stdlib/contrib/sranka/webexteams/webexteams.flux": "7f406dc24a30b217555967db42543ba4a36ec54972420cda575349063d38e3a4",
"stdlib/contrib/sranka/teams/teams.flux": "d0ea70602caa643baeb2ea12a8b51d0e2bd2d3c16ac21eaf812eefe97928b65a",
"stdlib/contrib/sranka/telegram/telegram.flux": "d0797f2e243a3c7922adb4484ee0e3bdade966963de4fded0e04178336d32801",
"stdlib/contrib/sranka/webexteams/webexteams.flux": "800c1f82c890d3e9c4356188c4170f018611aa194d4d0f06efe1ed706371d5f4",
"stdlib/contrib/tomhollingworth/events/duration.flux": "611336375816b73cdb7c9c711501c9dbd2e653720b7725f6e658974e3bd6181c",
"stdlib/contrib/tomhollingworth/events/duration_test.flux": "41500a9a391b5e6aa3fb7aa4db6db5e414947be5251736d91ae498d06d1f851e",
"stdlib/contrib/tomhollingworth/events/duration_with_stop_test.flux": "dbecebfe7aaeb988efad6d2160e8f5df28f6816ec6d61d1ccbe9bee99af2f144",
@@ -232,7 +232,7 @@ var sourceHashes = map[string]string{
"stdlib/experimental/window_test.flux": "d5370d2dad30ab536db0584516a46df668eadd59d19bc95885d8a4a0b720bb16",
"stdlib/generate/from_test.flux": "f4b773acadddf8318f1e6c0cc961ca36e22a4016378219e71d58f58fd2264c88",
"stdlib/generate/generate.flux": "2f705b8e44f0b8c64478ad59ccfab09d05c04666b1ab7279629afe1c35c75002",
"stdlib/http/http.flux": "b1e02153693002f80134f6bd76108afa11f7a0c4ee041bcfc17c373c1a6c1338",
"stdlib/http/http.flux": "f1482afe4e9bd1deca2a5fd3f2e68ce84379029003870db552ea44c78b236113",
"stdlib/http/http_path_encode_endpoint_test.flux": "cb1e075f9d0f5d2a2d46b6cec6a8e34eb932f3d31b5494f48a3135c9503d4038",
"stdlib/http/requests/requests.flux": "f88df79b7918f5ab92860197118070bc05f9bbbd9a7261462cecd367dfeeb704",
"stdlib/influxdata/influxdb/influxdb.flux": "e6b28fcea063420a83cdbcb54e4c40d28d28aa27c4b59b012eed7ac8ea6896a4",
@@ -334,13 +334,13 @@ var sourceHashes = map[string]string{
"stdlib/planner/window_sum_eval_test.flux": "460d45de75419da033d9bdf0b9a8c0d1bbdb57ed0d02f44d5f55d4d4b45086f1",
"stdlib/planner/window_sum_push_test.flux": "7ae2d85c889e95134d3976daf01bccacef9b350ef7657400c2c70213fe0c419f",
"stdlib/profiler/profiler.flux": "8e5c0ca87f0c5207c05fa1d0748f008767cf2e7e5451f6bd34a4eb3432573f7a",
"stdlib/pushbullet/pushbullet.flux": "beaca345921767bcdba03d27dab706fe3cb5d69c6d774f50a71e3ab84a2b4f55",
"stdlib/pushbullet/pushbullet.flux": "d6af5b945c03a93492b563fc8374afddc4ac2d966f33882ea9ec350befa67850",
"stdlib/regexp/regexp.flux": "5d9d67f486f4496bc367a0d64fe5e2f96d760f039a7c22b5da9cb9186f58c188",
"stdlib/regexp/replaceAllString_test.flux": "27fedcb986eed1e2de04c78520c7193c67a2bc9dae8b867401dde3c5d40b6b9a",
"stdlib/runtime/runtime.flux": "335db8189403e4ddc9b2cbfddc6a8ddfacd0b15bde3e00725b7aef8be0991d63",
"stdlib/sampledata/sampledata.flux": "57aba09baae57dd99d853b047df2d3047fbf47ea69de4869ef7eac3ad8a6e8ed",
"stdlib/sampledata/sampledata_test.flux": "70ba091a51d036a8cc25931808a39d81cf5d6dd17c2c7a5a081eb83fcfe5dd20",
"stdlib/slack/slack.flux": "395d96eed6a8f8f6b275e8cc2f46f20326b92eff3cbb6a6583f216f146296d55",
"stdlib/slack/slack.flux": "71563bf90727c1cfeeed0701b5b17d2a941a0abb951846a53271e54f8363074a",
"stdlib/socket/socket.flux": "89b9c350c5cf8df5056a45623309be681c5472eadb9088ff5ee59a8c50b879b2",
"stdlib/sql/sql.flux": "5b8a6176c2775e09abccdbef24cd2db68e60c34d493b451a217100b1e84cac0e",
"stdlib/sql/sql_test.flux": "69b61fc1208bb986c14f2e50b004c5bf5004f9cdcfefad0313b5d3981184e1a3",
41 changes: 19 additions & 22 deletions stdlib/contrib/bonitoo-io/alerta/alerta.flux
Original file line number Diff line number Diff line change
@@ -195,28 +195,25 @@ endpoint = (url, apiKey, environment="", origin="") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
alert(
url: url,
apiKey: apiKey,
resource: obj.resource,
event: obj.event,
environment: environment,
severity: obj.severity,
service: obj.service,
group: obj.group,
value: obj.value,
text: obj.text,
tags: obj.tags,
attributes: obj.attributes,
origin: origin,
type: obj.type,
timestamp: obj.timestamp,
)

return {r with _sent:
string(
v:
2 == alert(
url: url,
apiKey: apiKey,
resource: obj.resource,
event: obj.event,
environment: environment,
severity: obj.severity,
service: obj.service,
group: obj.group,
value: obj.value,
text: obj.text,
tags: obj.tags,
attributes: obj.attributes,
origin: origin,
type: obj.type,
timestamp: obj.timestamp,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
41 changes: 17 additions & 24 deletions stdlib/contrib/bonitoo-io/servicenow/servicenow.flux
Original file line number Diff line number Diff line change
@@ -207,30 +207,23 @@ endpoint = (url, username, password, source="Flux") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
event(
url: url,
username: username,
password: password,
source: source,
node: obj.node,
metricType: obj.metricType,
resource: obj.resource,
metricName: obj.metricName,
messageKey: obj.messageKey,
description: obj.description,
severity: obj.severity,
additionalInfo:
record.get(r: obj, key: "additionalInfo", default: record.any),
)

return {r with _sent:
string(
v:
2 == event(
url: url,
username: username,
password: password,
source: source,
node: obj.node,
metricType: obj.metricType,
resource: obj.resource,
metricName: obj.metricName,
messageKey: obj.messageKey,
description: obj.description,
severity: obj.severity,
additionalInfo:
record.get(
r: obj,
key: "additionalInfo",
default: record.any,
),
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
25 changes: 11 additions & 14 deletions stdlib/contrib/bonitoo-io/victorops/victorops.flux
Original file line number Diff line number Diff line change
@@ -167,20 +167,17 @@ endpoint = (url, monitoringTool="InfluxDB") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
alert(
url: url,
messageType: obj.messageType,
entityID: obj.entityID,
entityDisplayName: obj.entityDisplayName,
stateMessage: obj.stateMessage,
timestamp: obj.timestamp,
monitoringTool: monitoringTool,
)

return {r with _sent:
string(
v:
2 == alert(
url: url,
messageType: obj.messageType,
entityID: obj.entityID,
entityDisplayName: obj.entityDisplayName,
stateMessage: obj.stateMessage,
timestamp: obj.timestamp,
monitoringTool: monitoringTool,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
43 changes: 20 additions & 23 deletions stdlib/contrib/bonitoo-io/zenoss/zenoss.flux
Original file line number Diff line number Diff line change
@@ -232,29 +232,26 @@ endpoint = (
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
event(
url: url,
username: username,
password: password,
apiKey: apiKey,
action: action,
method: method,
type: type,
tid: tid,
summary: obj.summary,
device: obj.device,
component: obj.component,
severity: obj.severity,
eventClass: obj.eventClass,
eventClassKey: obj.eventClassKey,
collector: obj.collector,
message: obj.message,
)

return {r with _sent:
string(
v:
2 == event(
url: url,
username: username,
password: password,
apiKey: apiKey,
action: action,
method: method,
type: type,
tid: tid,
summary: obj.summary,
device: obj.device,
component: obj.component,
severity: obj.severity,
eventClass: obj.eventClass,
eventClassKey: obj.eventClassKey,
collector: obj.collector,
message: obj.message,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
21 changes: 9 additions & 12 deletions stdlib/contrib/chobbs/discord/discord.flux
Original file line number Diff line number Diff line change
@@ -129,18 +129,15 @@ endpoint = (webhookToken, webhookID, username, avatar_url="") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
send(
webhookToken: webhookToken,
webhookID: webhookID,
username: username,
avatar_url: avatar_url,
content: obj.content,
)

return {r with _sent:
string(
v:
2 == send(
webhookToken: webhookToken,
webhookID: webhookID,
username: username,
avatar_url: avatar_url,
content: obj.content,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
21 changes: 9 additions & 12 deletions stdlib/contrib/rhajek/bigpanda/bigpanda.flux
Original file line number Diff line number Diff line change
@@ -218,18 +218,15 @@ endpoint = (url=defaultUrl, token, appKey) =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
sendAlert(
url: url,
appKey: appKey,
token: token,
status: obj.status,
rec: obj,
)

return {r with _sent:
string(
v:
2 == sendAlert(
url: url,
appKey: appKey,
token: token,
status: obj.status,
rec: obj,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
35 changes: 16 additions & 19 deletions stdlib/contrib/sranka/opsgenie/opsgenie.flux
Original file line number Diff line number Diff line change
@@ -185,25 +185,22 @@ endpoint = (url="https://api.opsgenie.com/v2/alerts", apiKey, entity="") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
sendAlert(
url: url,
apiKey: apiKey,
entity: entity,
message: obj.message,
alias: obj.alias,
description: obj.description,
priority: obj.priority,
responders: obj.responders,
tags: obj.tags,
actions: obj.actions,
visibleTo: obj.visibleTo,
details: obj.details,
)

return {r with _sent:
string(
v:
2 == sendAlert(
url: url,
apiKey: apiKey,
entity: entity,
message: obj.message,
alias: obj.alias,
description: obj.description,
priority: obj.priority,
responders: obj.responders,
tags: obj.tags,
actions: obj.actions,
visibleTo: obj.visibleTo,
details: obj.details,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
20 changes: 8 additions & 12 deletions stdlib/contrib/sranka/teams/teams.flux
Original file line number Diff line number Diff line change
@@ -132,18 +132,14 @@ endpoint = (url) =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
message(
url: url,
title: obj.title,
text: obj.text,
summary: if exists obj.summary then obj.summary else "",
)

return {r with _sent:
string(
v:
2 == message(
url: url,
title: obj.title,
text: obj.text,
summary:
if exists obj.summary then obj.summary else "",
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
25 changes: 11 additions & 14 deletions stdlib/contrib/sranka/telegram/telegram.flux
Original file line number Diff line number Diff line change
@@ -177,20 +177,17 @@ endpoint = (
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
message(
url: url,
token: token,
channel: obj.channel,
text: obj.text,
parseMode: parseMode,
disableWebPagePreview: disableWebPagePreview,
silent: obj.silent,
)

return {r with _sent:
string(
v:
2 == message(
url: url,
token: token,
channel: obj.channel,
text: obj.text,
parseMode: parseMode,
disableWebPagePreview: disableWebPagePreview,
silent: obj.silent,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
21 changes: 9 additions & 12 deletions stdlib/contrib/sranka/webexteams/webexteams.flux
Original file line number Diff line number Diff line change
@@ -121,18 +121,15 @@ endpoint = (url="https://webexapis.com", token) =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
message(
url: url,
token: token,
roomId: obj.roomId,
text: obj.text,
markdown: obj.markdown,
)

return {r with _sent:
string(
v:
2 == message(
url: url,
token: token,
roomId: obj.roomId,
text: obj.text,
markdown: obj.markdown,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
7 changes: 2 additions & 5 deletions stdlib/http/http.flux
Original file line number Diff line number Diff line change
@@ -159,12 +159,9 @@ endpoint = (url) =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp = post(url: url, headers: obj.headers, data: obj.data)

return {r with _sent:
string(
v: 200 == post(url: url, headers: obj.headers, data: obj.data),
),
}
return {r with _status: string(v: resp), _sent: string(v: 200 == resp)}
},
)
|> experimental.group(mode: "extend", columns: ["_sent"])
13 changes: 2 additions & 11 deletions stdlib/pushbullet/pushbullet.flux
Original file line number Diff line number Diff line change
@@ -115,17 +115,8 @@ endpoint = (url=defaultURL, token="") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp = pushNote(url: url, token: token, title: obj.title, text: obj.text)

return {r with _sent:
string(
v:
2 == pushNote(
url: url,
token: token,
title: obj.title,
text: obj.text,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)
21 changes: 9 additions & 12 deletions stdlib/slack/slack.flux
Original file line number Diff line number Diff line change
@@ -156,18 +156,15 @@ endpoint = (url=defaultURL, token="") =>
|> map(
fn: (r) => {
obj = mapFn(r: r)
resp =
message(
url: url,
token: token,
channel: obj.channel,
text: obj.text,
color: obj.color,
)

return {r with _sent:
string(
v:
2 == message(
url: url,
token: token,
channel: obj.channel,
text: obj.text,
color: obj.color,
) / 100,
),
}
return {r with _status: string(v: resp), _sent: string(v: 2 == resp / 100)}
},
)