store more metadata
This commit is contained in:
parent
9409f6ee02
commit
60b88dd4d4
|
|
@ -132,7 +132,7 @@ export const ingest = new Elysia()
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const [ping] = await sql`
|
const [ping] = await sql`
|
||||||
INSERT INTO pings (monitor_id, checked_at, scheduled_at, jitter_ms, status_code, latency_ms, up, important, error, meta, region, run_id, cert_expiry_days)
|
INSERT INTO pings (monitor_id, checked_at, scheduled_at, jitter_ms, status_code, latency_ms, up, important, error, meta, region, run_id, cert_expiry_days, cert_issuer, response_size)
|
||||||
VALUES (
|
VALUES (
|
||||||
${body.monitor_id},
|
${body.monitor_id},
|
||||||
${checkedAt ?? sql`now()`},
|
${checkedAt ?? sql`now()`},
|
||||||
|
|
@ -146,7 +146,9 @@ export const ingest = new Elysia()
|
||||||
${Object.keys(meta).length > 0 ? sql.json(meta) : null},
|
${Object.keys(meta).length > 0 ? sql.json(meta) : null},
|
||||||
${region},
|
${region},
|
||||||
${body.run_id ?? null},
|
${body.run_id ?? null},
|
||||||
${body.cert_expiry_days ?? null}
|
${body.cert_expiry_days ?? null},
|
||||||
|
${body.cert_issuer ?? null},
|
||||||
|
${body.response_size ?? null}
|
||||||
)
|
)
|
||||||
RETURNING *
|
RETURNING *
|
||||||
`;
|
`;
|
||||||
|
|
@ -197,6 +199,7 @@ export const ingest = new Elysia()
|
||||||
error: t.Optional(t.Nullable(t.String())),
|
error: t.Optional(t.Nullable(t.String())),
|
||||||
cert_expiry_days: t.Optional(t.Nullable(t.Number())),
|
cert_expiry_days: t.Optional(t.Nullable(t.Number())),
|
||||||
cert_issuer: t.Optional(t.Nullable(t.String())),
|
cert_issuer: t.Optional(t.Nullable(t.String())),
|
||||||
|
response_size: t.Optional(t.Nullable(t.Number())),
|
||||||
meta: t.Optional(t.Any()),
|
meta: t.Optional(t.Any()),
|
||||||
region: t.Optional(t.Nullable(t.String())),
|
region: t.Optional(t.Nullable(t.String())),
|
||||||
run_id: t.Optional(t.Nullable(t.String())),
|
run_id: t.Optional(t.Nullable(t.String())),
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ pub async fn fetch_and_run(
|
||||||
error: Some(format!("timed out after {}ms", timeout_ms)),
|
error: Some(format!("timed out after {}ms", timeout_ms)),
|
||||||
cert_expiry_days: None,
|
cert_expiry_days: None,
|
||||||
cert_issuer: None,
|
cert_issuer: None,
|
||||||
|
response_size: None,
|
||||||
meta: None,
|
meta: None,
|
||||||
region: Some(region_owned.to_string()),
|
region: Some(region_owned.to_string()),
|
||||||
run_id: Some(run_id_owned.clone()),
|
run_id: Some(run_id_owned.clone()),
|
||||||
|
|
@ -271,6 +272,7 @@ async fn run_check(client: &reqwest::Client, monitor: &Monitor, scheduled_at: Op
|
||||||
error: query_error,
|
error: query_error,
|
||||||
cert_expiry_days,
|
cert_expiry_days,
|
||||||
cert_issuer,
|
cert_issuer,
|
||||||
|
response_size: Some(body.len()),
|
||||||
meta: Some(meta),
|
meta: Some(meta),
|
||||||
region: Some(region.to_string()),
|
region: Some(region.to_string()),
|
||||||
run_id: Some(run_id.to_string()),
|
run_id: Some(run_id.to_string()),
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ pub struct PingResult {
|
||||||
pub error: Option<String>,
|
pub error: Option<String>,
|
||||||
pub cert_expiry_days: Option<i64>,
|
pub cert_expiry_days: Option<i64>,
|
||||||
pub cert_issuer: Option<String>,
|
pub cert_issuer: Option<String>,
|
||||||
|
pub response_size: Option<usize>,
|
||||||
pub meta: Option<Value>,
|
pub meta: Option<Value>,
|
||||||
pub region: Option<String>,
|
pub region: Option<String>,
|
||||||
pub run_id: Option<String>,
|
pub run_id: Option<String>,
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ export async function migrate(sql: any) {
|
||||||
meta JSONB,
|
meta JSONB,
|
||||||
region TEXT NOT NULL DEFAULT 'default',
|
region TEXT NOT NULL DEFAULT 'default',
|
||||||
run_id TEXT,
|
run_id TEXT,
|
||||||
cert_expiry_days INTEGER
|
cert_expiry_days INTEGER,
|
||||||
|
cert_issuer TEXT,
|
||||||
|
response_size INTEGER
|
||||||
)
|
)
|
||||||
`;
|
`;
|
||||||
await sql`CREATE INDEX IF NOT EXISTS idx_pings_monitor ON pings(monitor_id, checked_at DESC)`;
|
await sql`CREATE INDEX IF NOT EXISTS idx_pings_monitor ON pings(monitor_id, checked_at DESC)`;
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,8 @@
|
||||||
if (ping.region) html += `<div class="text-gray-500">Region</div><div class="text-gray-300">${escapeHtml(ping.region)}</div>`;
|
if (ping.region) html += `<div class="text-gray-500">Region</div><div class="text-gray-300">${escapeHtml(ping.region)}</div>`;
|
||||||
if (ping.run_id) html += `<div class="text-gray-500">Run ID</div><div class="text-gray-300 font-mono break-all">${escapeHtml(ping.run_id)}</div>`;
|
if (ping.run_id) html += `<div class="text-gray-500">Run ID</div><div class="text-gray-300 font-mono break-all">${escapeHtml(ping.run_id)}</div>`;
|
||||||
if (ping.cert_expiry_days != null) html += `<div class="text-gray-500">Cert expiry</div><div class="text-gray-300">${ping.cert_expiry_days} days</div>`;
|
if (ping.cert_expiry_days != null) html += `<div class="text-gray-500">Cert expiry</div><div class="text-gray-300">${ping.cert_expiry_days} days</div>`;
|
||||||
|
if (ping.cert_issuer) html += `<div class="text-gray-500">Cert issuer</div><div class="text-gray-300">${escapeHtml(ping.cert_issuer)}</div>`;
|
||||||
|
if (ping.response_size != null) html += `<div class="text-gray-500">Response size</div><div class="text-gray-300">${ping.response_size >= 1024 ? (ping.response_size / 1024).toFixed(1) + ' KB' : ping.response_size + ' B'}</div>`;
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
// Error
|
// Error
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue