← スキル一覧に戻る

monitoring-expert
by ripgraphics
New Author's Info Project
⭐ 0🍴 0📅 2026年1月25日
SKILL.md
name: monitoring-expert description: >- Monitoring and observability expert. Logging, metrics, error tracking, health checks. Use for production monitoring setup.
Monitoring Expert
Logging (Node.js)
// Using Pino (fast)
import pino from 'pino';
const logger = pino({
level: process.env.LOG_LEVEL || 'info',
transport: process.env.NODE_ENV !== 'production'
? { target: 'pino-pretty' }
: undefined
});
// Usage
logger.info({ userId: 123 }, 'User logged in');
logger.error({ err, requestId }, 'Failed to process');
// Express middleware
import pinoHttp from 'pino-http';
app.use(pinoHttp({ logger }));
Error Tracking (Sentry)
import * as Sentry from '@sentry/node';
Sentry.init({
dsn: process.env.SENTRY_DSN,
environment: process.env.NODE_ENV,
tracesSampleRate: 0.1,
});
// Capture errors
try {
riskyOperation();
} catch (error) {
Sentry.captureException(error);
throw error;
}
// Express error handler
app.use(Sentry.Handlers.errorHandler());
Health Checks
// /health endpoint
app.get('/health', async (req, res) => {
const health = {
status: 'ok',
timestamp: new Date().toISOString(),
uptime: process.uptime(),
checks: {
database: await checkDatabase(),
redis: await checkRedis(),
}
};
const isHealthy = Object.values(health.checks).every(v => v === 'ok');
res.status(isHealthy ? 200 : 503).json(health);
});
async function checkDatabase() {
try {
await prisma.$queryRaw`SELECT 1`;
return 'ok';
} catch { return 'error'; }
}
Metrics (Prometheus)
import promClient from 'prom-client';
// Default metrics
promClient.collectDefaultMetrics();
// Custom metrics
const httpRequestDuration = new promClient.Histogram({
name: 'http_request_duration_seconds',
help: 'HTTP request duration',
labelNames: ['method', 'route', 'status'],
});
// Middleware
app.use((req, res, next) => {
const end = httpRequestDuration.startTimer();
res.on('finish', () => {
end({ method: req.method, route: req.path, status: res.statusCode });
});
next();
});
// Endpoint
app.get('/metrics', async (req, res) => {
res.set('Content-Type', promClient.register.contentType);
res.end(await promClient.register.metrics());
});
Quick Debug Commands
# Check logs
journalctl -u myapp -f --since "1 hour ago"
docker logs -f --tail 100 container_name
# Check resources
htop
df -h
free -m
# Network
netstat -tlnp
ss -tlnp
curl -I http://localhost:3000/health
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です