Prometheus Integration¶
Setting up the webhook¶
Robusta playbooks can run in response to any Prometheus alert. To configure, add the robusta-runner webhook to your alert manager configuration:
AlertManager configuration
receivers:
- name: 'webhook'
webhook_configs:
- url: 'http://robusta-runner.default.svc.cluster.local/api/alerts'
send_resolved: true
Warning
If you use the Prometheus Operator, use a manually managed secret and not an AlertmanagerConfig due to this limitation.
Trying it out¶
You can now write and use a playbook action like the following:
Example Prometheus playbook
@action
def my_action(alert: PrometheusKubernetesAlert):
print(f"The alert {alert.alert_name} fired on pod {alert.pod.metadata.name}")
print(f"The pod has these processes:", alert.pod.exec("ps aux"))
print(f"The pod has {len(alert.pod.spec.containers)} containers")
Tip
alert.pod
is a Kubernetes pod object. It has the same fields as a Pod yaml. For example, alert.pod.metadata.name
maps to metadata.name
in the yaml.