Skip to content

Commit 00ed130

Browse files
Add ability to define a link on a node
1 parent 314e469 commit 00ed130

File tree

7 files changed

+62
-1
lines changed

7 files changed

+62
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,8 @@ You can also use environment variables with string interpolation in your configu
345345
* `http_body` (type _string_, allowed: any string, no default) — Body to send in the HTTP request when polling an endpoint (this only works if `http_method` is set to `POST`, `PUT` or `PATCH`)
346346
* `http_body_healthy_match` (type: _string_, allowed: regular expressions, no default) — HTTP response body for which to report node replica as `healthy` (if the body does not match, the replica will be reported as `dead`, even if the status code check passes; the check uses a `GET` rather than the usual `HEAD` if this option is set)
347347
* `reveal_replica_name` (type: _boolean_, allowed: `true`, `false`, default: `false`) — Whether to reveal replica name on public status page or not (this can be a security risk if a replica URL is to be kept secret)
348+
* `link_url` (type: _string_, allowed: URL, no default) — Link URL to show next to the node health (this can be used to direct the user to another page to see more details)
349+
* `link_label` (type: _string_, allowed: any string, no default) — Link label to use for the URL link (if any link is set)
348350
* `rabbitmq_queue` (type: _string_, allowed: RabbitMQ queue names, no default) — RabbitMQ queue associated to node, which to check against for pending payloads via RabbitMQ API (this helps monitor unacked payloads accumulating in the queue)
349351
* `rabbitmq_queue_nack_healthy_below` (type: _integer_, allowed: any number, no default) — Maximum number of payloads in RabbitMQ queue associated to node, with status `nack` to consider node `healthy` (this overrides the global `plugins.rabbitmq.queue_nack_healthy_below`)
350352
* `rabbitmq_queue_nack_dead_above` (type: _integer_, allowed: any number, no default) — Threshold on the number of payloads in RabbitMQ queue associated to node, with status `nack` above which node should be considered `dead` (stalled queue, this overrides the global `plugins.rabbitmq.queue_nack_dead_above`)

config.cfg

+29
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,32 @@ mode = "local"
233233
id = "capacity"
234234
label = "Network capacity"
235235
mode = "local"
236+
237+
[[probe.service]]
238+
239+
id = "plugin"
240+
label = "Plugin nodes"
241+
242+
[[probe.service.node]]
243+
244+
id = "plugin-health"
245+
label = "Plugins health"
246+
mode = "script"
247+
link_url = "https://status.plugins.crisp.chat/"
248+
link_label = "See status details"
249+
250+
scripts = [
251+
'''
252+
status=$(curl --silent --connect-timeout 3 https://status.plugins.crisp.chat/status/text)
253+
254+
if [ -z "$status" ]; then
255+
exit 2
256+
fi
257+
258+
if [ "$status" = "healthy" ]; then
259+
exit 0
260+
fi
261+
262+
exit 1
263+
'''
264+
]

res/assets/stylesheets/index.css

+14-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ main section.probe ul li label {
328328

329329
main section.probe ul li .node {
330330
background-color: #F7F8FA;
331-
padding: 9px 20px 8px 24px;
331+
padding: 9px 14px 8px 24px;
332332
flex: 0.65;
333333
}
334334

@@ -344,6 +344,19 @@ main section.probe ul li .node .replica {
344344
border-radius: 2px;
345345
}
346346

347+
main section.probe ul li .node .replica:last-of-type {
348+
margin-right: 8px;
349+
}
350+
351+
main section.probe ul li .node .link {
352+
color: #000000;
353+
font-size: 12px;
354+
line-height: 16px;
355+
text-decoration: underline;
356+
margin-top: 7px;
357+
display: inline-block;
358+
}
359+
347360
footer {
348361
text-align: center;
349362
letter-spacing: -0.05px;

res/assets/templates/index.tera

+10
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@
212212
</span>
213213
</span>
214214
{% endfor %}
215+
216+
{% if node.link_url %}
217+
<a href="{{ node.link_url | escape }}" class="link font-sans-semibold">
218+
{% if node.link_label %}
219+
{{ node.link_label }}
220+
{% else %}
221+
{{ node.link_url }}
222+
{% endif %}
223+
</a>
224+
{% endif %}
215225
</div>
216226
</li>
217227
{% endfor %}

src/config/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ pub struct ConfigProbeServiceNode {
309309
#[serde(default = "defaults::probe_service_node_reveal_replica_name")]
310310
pub reveal_replica_name: bool,
311311

312+
pub link_url: Option<SerdeUrl>,
313+
pub link_label: Option<String>,
314+
312315
pub rabbitmq_queue: Option<String>,
313316
pub rabbitmq_queue_nack_healthy_below: Option<u32>,
314317
pub rabbitmq_queue_nack_dead_above: Option<u32>,

src/prober/manager.rs

+2
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,8 @@ pub fn initialize_store() {
874874
http_body: node.http_body.to_owned(),
875875
http_body_healthy_match: node.http_body_healthy_match.to_owned(),
876876
reveal_replica_name: node.reveal_replica_name,
877+
link_url: node.link_url.as_ref().map(|url| url.to_string()),
878+
link_label: node.link_label.to_owned(),
877879
rabbitmq: node.rabbitmq_queue.as_ref().map(|queue| {
878880
ServiceStatesProbeNodeRabbitMQ {
879881
queue: queue.to_owned(),

src/prober/states.rs

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub struct ServiceStatesProbeNode {
4242
pub http_body: Option<String>,
4343
pub http_body_healthy_match: Option<Regex>,
4444
pub reveal_replica_name: bool,
45+
pub link_url: Option<String>,
46+
pub link_label: Option<String>,
4547
pub rabbitmq: Option<ServiceStatesProbeNodeRabbitMQ>,
4648
}
4749

0 commit comments

Comments
 (0)