Skip to content
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
55 changes: 45 additions & 10 deletions discord-scripts/incident-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ import { Robot } from "hubot"

// Set to #alarm-trigger channel
const CHANNEL_ID = "1377183184902688862"
const { INCIDENT_ROUTING_KEY } = process.env
const { CRITICAL_INCIDENT_ROUTING_KEY, HIGH_INCIDENT_ROUTING_KEY } = process.env

export default async function incidentReport(
discordClient: Client,
robot: Robot,
) {
if (!INCIDENT_ROUTING_KEY) {
if (!CRITICAL_INCIDENT_ROUTING_KEY) {
robot.logger.error(
"INCIDENT_ROUTING_KEY is not set. Skipping incident report setup.",
"CRITICAL_INCIDENT_ROUTING_KEY is not set. Skipping incident report setup.",
)
return
}
if (!HIGH_INCIDENT_ROUTING_KEY) {
robot.logger.error(
"HIGH_INCIDENT_ROUTING_KEY is not set. Skipping incident report setup.",
)
return
}
Expand Down Expand Up @@ -50,9 +56,13 @@ export default async function incidentReport(

const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder()
.setCustomId("incident_yes")
.setLabel("🚨 Wake Someone Up!")
.setCustomId("incident_critical")
.setLabel("🚨 Critical: Security incident or chain halt")
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId("incident_high")
.setLabel("🛎 High: Other high severity incident")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("incident_no")
.setLabel("Don't Trigger")
Expand All @@ -63,7 +73,6 @@ export default async function incidentReport(
await message.reply({
content: `**Before triggering an alert, ask yourself:**
- Is this incident truly a Critical or High severity issue?
- Could this wait until regular business hours without major impact?
- Can I resolve this with existing documentation or procedures?`,

components: [row],
Expand All @@ -79,24 +88,50 @@ export default async function incidentReport(
async (interaction: Interaction) => {
if (!interaction.isButton()) return

if (interaction.customId === "incident_yes") {
if (interaction.customId === "incident_critical") {
try {
await fetch("https://events.pagerduty.com/v2/enqueue", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
payload: {
summary: "Mezo Critical alert triggered from Discord",
summary: "Mezo Security alert triggered from Discord",
severity: "critical",
source: "Mezo",
},
routing_key: INCIDENT_ROUTING_KEY,
routing_key: CRITICAL_INCIDENT_ROUTING_KEY,
event_action: "trigger",
}),
})

await interaction.reply({
content: "🚨 Critical severity alert has been triggered. Escalating to the Security Response group.",
})
} catch (error) {
robot.logger.error("❌ Failed to trigger alert:", error)
await interaction.reply({
content: "⚠️ Failed to trigger alert.",
})
}
} else if (interaction.customId === "incident_high") {
try {
await fetch("https://events.pagerduty.com/v2/enqueue", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
payload: {
summary: "Mezo High severity alert triggered from Discord",
severity: "critical", // PagerDuty does not support "high"
source: "Mezo",
},
routing_key: HIGH_INCIDENT_ROUTING_KEY,
event_action: "trigger",
}),
})

await interaction.reply({
content: "🚨 Alert has been triggered.",
content:
"🛎 High severity alert has been triggered. Note these are handled during business hours.",
})
} catch (error) {
robot.logger.error("❌ Failed to trigger alert:", error)
Expand Down
5 changes: 3 additions & 2 deletions infrastructure/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ RUN apk add --no-cache \
git && \
rm -rf /usr/share/man/

# Install pnpm
RUN npm install -g pnpm
# Install pnpm. Pin to v9, the last major that still supports the Node 18
# runtime this image is built on (pnpm 10 requires Node >=22.13).
RUN npm install -g pnpm@9

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Workaround to unblock. Separately, we need to do something similar to what was done in https://github.com/mezo-org/web/pull/539.


COPY pnpm-lock.yaml package.json ./

Expand Down
11 changes: 8 additions & 3 deletions infrastructure/kube/thesis-ops/valkyrie-hubot-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ spec:
spec:
containers:
- name: hubot
# image: gcr.io/thesis-ops-2748/valkyrie:571907d25da706484e12f7d8c40e03a9d82105a8
# image: gcr.io/thesis-ops-2748/valkyrie:571907d25da706484e12f7d8c40e03a9d82105a8
env:
- name: ANTHROPIC_API_KEY
valueFrom:
Expand Down Expand Up @@ -97,11 +97,16 @@ spec:
secretKeyRef:
name: valkyrie-hubot
key: imgflip_api_username
- name: INCIDENT_ROUTING_KEY
- name: CRITICAL_INCIDENT_ROUTING_KEY
valueFrom:
secretKeyRef:
name: valkyrie-hubot
key: incident_routing_key
key: critical_incident_routing_key
- name: HIGH_INCIDENT_ROUTING_KEY
valueFrom:
secretKeyRef:
name: valkyrie-hubot
key: high_incident_routing_key
- name: IMGFLIP_API_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
Loading