用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ffsshhttiikk/opencode-agents-skills --skill log-management命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | log-management |
| description | Centralized logging and analysis |
| license | MIT |
| compatibility | opencode |
| metadata | {"audience":"developer, devops-engineer, sre","category":"devops"} |
┌─────────────────────────────────────────────────────┐
│ Application Logs │
│ (stdout, file, syslog) │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Log Collector │
│ (Fluentd, Filebeat, Vector) │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Log Storage │
│ (Elasticsearch, Loki, S3) │
└──────────────────────┬──────────────────────────────┘
│
┌──────────────────────▼──────────────────────────────┐
│ Visualization │
│ (Kibana, Grafana, CloudWatch) │
└─────────────────────────────────────────────────────┘
<source>
@type tail
@id input_tail
path /var/log/nginx/access.log
pos_file /var/log/fluentd/nginx-access.log.pos
tag nginx.access
<parse>
@type nginx
</parse>
</source>
<filter nginx.access>
@type parser
key_name log
<parse>
@type json
</parse>
</filter>
<match nginx.**>
@type elasticsearch
host elasticsearch
port 9200
logstash_format true
logstash_prefix nginx
flush_interval 10s
</match>
# Find error logs
{job="myapp"} |= "ERROR"
# Exclude health checks
{job="myapp"} != "/health"
# Parse JSON logs
{job="myapp"} | json | level="error"
# Rate calculation
sum(rate({job="myapp"}[5m]))
# Latency percentiles
histogram_quantile(0.99, sum(rate({job="myapp"}[5m])) by (le, path))
import logging
import json
from datetime import datetime
class JSONFormatter(logging.Formatter):
def format(self, record):
log_data = {
"timestamp": datetime.utcnow().isoformat(),
"level": record.levelname,
"message": record.getMessage(),
"module": record.module,
"function": record.funcName,
"line": record.lineno
}
if record.exc_info:
log_data["exception"] = self.formatException(record.exc_info)
if hasattr(record, "user_id"):
log_data["user_id"] = record.user_id
if hasattr(record, "request_id"):
log_data["request_id"] = record.request_id
return json.dumps(log_data)
# Usage
logger = logging.getLogger(__name__)
logger.info("User logged in", extra={"user_id": 123, "request_id": "abc"})
# docker-compose.yml
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.10.0
environment:
- discovery.type=single-node
- xpack.security.enabled=false
ports:
- "9200:9200"
kibana:
image: docker.elastic.co/kibana/kibana:8.10.0
ports:
- "5601:5601"
depends_on:
- elasticsearch
logstash:
image: docker.elastic.co/logstash/logstash:8.10.0
ports:
- "5044:5044"
volumes:
- ./logstash.conf:/usr/share/logstash/pipeline/logstash.conf
| Data Type | Retention | Storage |
|---|---|---|
| Application Logs | 30 days | Hot |
| Audit Logs | 1 year | Warm |
| Security Logs | 2 years | Cold |
| Compliance Logs | 7 years | Archive |