当前位置: 首页 > Skill >

AMG PostgreSQL Flexible Server Health Check

AMG PostgreSQL Flexible Server Health Check

1.0.0 2026.11.12 浏览:652
获取Skill文件查看使用说明
作者:许宁许可证:
本文目录展开

<!-- Auto-generated for OpenClaw by pack-openclaw. Notes for OpenClaw users:
- Claude Code dynamic expressions (!`...`) in this file are NOT evaluated by OpenClaw
and appear as literal text. Run them manually at the start of the workflow.
- Invoke this skill only via slash command (e.g. /amg-check-pg-flex). Auto-invocation is
disabled on Claude Code but not on OpenClaw. -->

<h2>OpenClaw Setup (one-time)</h2>
<p>This skill calls MCP tools prefixed with <code>mcp__amg__*</code>, so OpenClaw must have an MCP server registered under the exact name <strong><code>amg</code></strong>. Run this once per workspace before invoking the skill:</p>
<pre><code class="language-bash">openclaw mcp set amg &#39;{&quot;url&quot;:&quot;https://&lt;your-grafana-instance&gt;/api/azure-mcp&quot;,&quot;transport&quot;:&quot;streamable-http&quot;,&quot;headers&quot;:{&quot;Authorization&quot;:&quot;Bearer &lt;your-token&gt;&quot;}}&#39;
</code></pre>
<p>Replace <code>&lt;your-grafana-instance&gt;</code> with your Azure Managed Grafana endpoint and <code>&lt;your-token&gt;</code> with a valid Grafana service-account token (starts with <code>glsa_</code>). The server name <strong>must</strong> be <code>amg</code> — the skill&#39;s <code>allowed-tools</code> reference <code>mcp__amg__*</code> and will not find tools under any other name.</p>
<p>Verify the server is registered:</p>
<pre><code class="language-bash">openclaw mcp list
</code></pre>
<blockquote>
<p>Official skill source: https://github.com/Azure/amg-skills</p>
</blockquote>
<h2>Runtime Context</h2>
<ul>
<li>Current UTC time: !<code>date -u +%Y-%m-%dT%H:%M:%SZ</code></li>
<li>Config: !<code>cat memory/amg-check-pg-flex/config.md 2&gt;/dev/null || echo &quot;NOT_CONFIGURED&quot;</code></li>
<li>Prior report: !<code>[ -f memory/amg-check-pg-flex/report.md ] &amp;&amp; echo &quot;exists ($(grep -c &#39;^### BUG-&#39; memory/amg-check-pg-flex/report.md) bugs documented)&quot; || echo &quot;not found&quot;</code></li>
<li>Arguments: time-range=$0, subscription-override=$1</li>
</ul>
<blockquote>
<p><strong>Known Issues</strong>: Before presenting findings, cross-reference results against <code>memory/amg-check-pg-flex/report.md</code>.</p>
</blockquote>
<h2>AMG PostgreSQL Flexible Server Health Check</h2>
<h2>Critical Constraints</h2>
<ul>
<li><strong>No subagents for MCP.</strong> The Agent tool cannot access MCP tools — all MCP calls must be made from the main context.</li>
<li><strong>Scan every resource.</strong> No sampling or early stopping.</li>
<li><strong>Time format</strong>: ISO 8601 UTC with explicit <code>from</code>/<code>to</code> — NEVER use <code>timespan</code> (it causes errors).</li>
<li><strong>Parallelism cap</strong>: 30 concurrent MCP calls per batch. Reduce to 4-5 if rate-limited.</li>
<li><strong>Result too large</strong>: Save to temp file and parse outside the context window. Prefer <code>node -e &quot;...&quot;</code> if installed; otherwise fall back to <code>python -c &quot;...&quot;</code>, <code>jq</code>, or <code>pwsh -Command &quot;...&quot;</code>. Bash permission for the chosen interpreter will be prompted on first use.</li>
</ul>
<h2>Progress Tracking</h2>
<p>Update checkboxes as you complete each phase:</p>
<ul>
<li><input disabled="" type="checkbox"> Phase 1a: Datasource validated</li>
<li><input disabled="" type="checkbox"> Phase 1b: Servers discovered (N=?)</li>
<li><input disabled="" type="checkbox"> Phase 1c: Non-ready servers investigated (if any)</li>
<li><input disabled="" type="checkbox"> Phase 2: Pulse check completed (N scanned, N findings)</li>
<li><input disabled="" type="checkbox"> Phase 3: Deep metrics for abnormal servers</li>
<li><input disabled="" type="checkbox"> Phase 4: Resource logs for abnormal servers</li>
<li><input disabled="" type="checkbox"> Report presented</li>
<li><input disabled="" type="checkbox"> Known issues updated in <code>memory/amg-check-pg-flex/report.md</code></li>
</ul>
<h2>Configuration</h2>
<p><strong>If Config shows <code>NOT_CONFIGURED</code></strong>: Run First-Run Setup at the bottom of this file, then return here.</p>
<p><strong>If Config is populated</strong>: Extract the datasource UID and subscription ID from the pre-loaded Runtime Context above and use them for all queries. Use <code>$1</code> as the subscription override if provided.</p>
<ul>
<li><strong>Datasource UID</strong>: from <code>## Azure Monitor Datasource</code> &gt; <code>UID</code></li>
<li><strong>Subscription ID</strong>: from <code>## Subscription</code> (or <code>$1</code> if provided)</li>
<li><strong>Resource Type</strong>: <code>microsoft.dbforpostgresql/flexibleservers</code> (lowercase)</li>
<li><strong>ARM ID template</strong>: <code>/subscriptions/{SUB}/resourceGroups/{RG}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{name}</code></li>
</ul>
<h2>Time Range</h2>
<p>Default: 7 days for metrics, 24 hours for logs. Override with <code>$0</code> (e.g., <code>3d</code>). Keep log queries to 1-2 days to avoid timeouts.</p>

<h2>Workflow</h2>
<h3>Phase 1a: Validate Datasource</h3>
<p>Call <code>amgmcp_datasource_list</code> (no parameters). Find entry with <code>type == &quot;grafana-azure-monitor-datasource&quot;</code>.</p>
<ul>
<li>Matches configured UID → proceed.</li>
<li>Different UID → update <code>memory/amg-check-pg-flex/config.md</code>, warn user, use new UID.</li>
<li>Not found → abort with error.</li>
</ul>
<h3>Phase 1b: Discover All PostgreSQL Flexible Servers</h3>
<pre><code>azureMonitorDatasourceUid: {DATASOURCE_UID}
query: |
resources
| where type == &#39;microsoft.dbforpostgresql/flexibleservers&#39;
| where subscriptionId == &#39;{SUBSCRIPTION_ID}&#39;
| project name, resourceGroup, location, properties.state, sku.name, sku.tier
| order by location asc, name asc
</code></pre>
<p>If multiple subscriptions are configured, query each separately and merge results. Derive region summary by counting servers per <code>location</code>. Flag servers not in &quot;Ready&quot; state. Stop if zero servers found.</p>
<h3>Phase 1c: Activity Log for Non-Ready Servers</h3>
<p>If any servers are not in &quot;Ready&quot; state, query the activity log for up to 3 of them:</p>
<pre><code>azureMonitorDatasourceUid: {DATASOURCE_UID}
scope: /subscriptions/{SUB}/resourceGroups/{RG}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{name}
startTime: now-3d
endTime: now
select: eventTimestamp,operationName,status,caller,subStatus
</code></pre>
<p>If the response exceeds 500 KB, retry with <code>startTime: now-6h</code>. Summarize: operations performed, caller type (service principal vs human), success/in-progress status, likely cause.</p>
<h3>Phase 2: Tier 1 — Fleet-Wide Pulse Check</h3>
<pre><code>azureMonitorDatasourceUid: {DATASOURCE_UID}
pastDays: 7
scenarios: pg_flex
</code></pre>
<p>Scans all servers across 5 scenarios: <code>pg_flex_cpu</code>, <code>pg_flex_memory</code>, <code>pg_flex_storage</code>, <code>pg_flex_disk_iops</code>, <code>pg_flex_disk_bandwidth</code>.</p>
<p><strong>Before moving to Phase 3, verify:</strong></p>
<ol>
<li><code>scanSummary.totalResourcesScanned</code> matches Phase 1 server count.</li>
<li>All 5 scenarios show <code>status: &quot;completed&quot;</code> in <code>scenarioResults</code>.</li>
<li>If <code>errors</code> non-empty, retry affected scenarios individually (e.g., <code>scenarios: pg_flex_cpu</code>).</li>
<li>If &gt;10% servers missing, fall back to batched <code>amgmcp_query_resource_metric</code> for unscanned servers.</li>
</ol>
<p><strong>Severity thresholds (findings array):</strong></p>
<table>
<thead>
<tr>
<th>Severity</th>
<th>CPU</th>
<th>Memory</th>
<th>Storage</th>
<th>Disk IOPS</th>
<th>Disk BW</th>
</tr>
</thead>
<tbody><tr>
<td>Critical</td>
<td>&gt;90%</td>
<td>&gt;90%</td>
<td>&gt;85%</td>
<td>&gt;90%</td>
<td>&gt;90%</td>
</tr>
<tr>
<td>Warning</td>
<td>&gt;80%</td>
<td>&gt;80%</td>
<td>&gt;75%</td>
<td>&gt;80%</td>
<td>&gt;80%</td>
</tr>
</tbody></table>
<h3>Phase 3: Tier 2 — Deep Metrics for Abnormal Servers</h3>
<p>Read <strong>reference/phase3-deep-dive.md</strong> before starting Phase 3. It contains:</p>
<ul>
<li>Core metrics table (always query) and secondary metrics table (query on anomaly)</li>
<li>Batch strategy: up to 50 comma-separated resource IDs per call, up to 5 parallel metric calls</li>
<li>Correlation analysis patterns (use ultrathink)</li>
</ul>
<h3>Phase 4: Resource Logs for Abnormal Servers</h3>
<p>Read <strong>reference/phase4-resource-logs.md</strong> before starting Phase 4. It contains:</p>
<ul>
<li>5 KQL query templates: error distribution, top errors, warning messages, log volume, session duration</li>
<li>Time filter rules (always required to avoid timeouts)</li>
</ul>

<h2>Output</h2>
<p>Present the report using the structure in <strong>reference/output-format.md</strong>.</p>
<p><strong>Classification:</strong></p>
<table>
<thead>
<tr>
<th>Severity</th>
<th>Criteria</th>
</tr>
</thead>
<tbody><tr>
<td><strong>CRITICAL</strong></td>
<td><code>is_db_alive</code> sustained 0, OR CPU max &gt;90%, OR Memory max &gt;90%, OR Storage &gt;85%</td>
</tr>
<tr>
<td><strong>WARNING</strong></td>
<td>CPU avg &gt;80%, Memory avg &gt;85%, sustained &gt;60% for 6h+, spike &gt;30pp in 1h, Storage &gt;70%, <code>connections_failed</code> &gt;0, <code>deadlocks</code> &gt;0, disk IOPS/BW &gt;80%, transactionIDs &gt;1B, longest query &gt;300s, replication delay &gt;30s</td>
</tr>
<tr>
<td><strong>HEALTHY</strong></td>
<td>All metrics within normal ranges</td>
</tr>
</tbody></table>
<h2>Update Known Issues</h2>
<p>After presenting findings, update <code>memory/amg-check-pg-flex/report.md</code>:</p>
<ol>
<li>Read the current file.</li>
<li>Rebuild the Resource Inventory table at the end: every server, full ARM ID, region, SKU, state. Group by region, sorted alphabetically.</li>
<li>Update existing bug status from today&#39;s telemetry (resolved / improving / worsening / still active).</li>
<li>Add new bugs with: severity, server name, region, metric evidence, log evidence, root cause, recommended action.</li>
<li>Update the &quot;Updated&quot; date header.</li>
</ol>
<p>Only add genuine issues: sustained high utilization, crash patterns, connection storms, persistent errors. Skip transient single-hour spikes or expected maintenance windows.</p>
<h2>Error Handling</h2>
<p>See <strong>reference/error-handling.md</strong> for the full recovery table.</p>
<h2>Analysis Guidance</h2>
<ul>
<li>Known patterns, signals, root causes: reference/analysis-patterns.md</li>
<li>Optional deep-dive KQL queries: reference/deep-dive-queries.md</li>
</ul>

<h2>First-Run Setup</h2>
<p>Run only when Config shows <code>NOT_CONFIGURED</code>. After completing, return to the Workflow above.</p>
<p><strong>1. Discover Datasource UID</strong>: Call <code>amgmcp_datasource_list</code>. Filter <code>type == &quot;grafana-azure-monitor-datasource&quot;</code>. Prefer <code>uid == &quot;azure-monitor-oob&quot;</code> if multiple match. Abort if zero match.</p>
<p><strong>2. Discover Subscription ID</strong>: Run this Resource Graph query to list all subscriptions with PostgreSQL Flexible Servers, then present the results as a table and ask the user which subscription(s) to use:</p>
<pre><code>resources
| where type == &#39;microsoft.dbforpostgresql/flexibleservers&#39;
| join kind=inner (
resourcecontainers
| where type == &#39;microsoft.resources/subscriptions&#39;
| project subscriptionId, subscriptionName=name
) on subscriptionId
| summarize ServerCount=count() by subscriptionId, subscriptionName
| order by ServerCount desc
</code></pre>
<p>Present the results as a table with columns: <strong>Subscription Name</strong>, <strong>Subscription ID</strong>, <strong>Server Count</strong>. Then ask the user: <em>&quot;Which subscription ID(s) should I configure for this health check?&quot;</em></p>
<p><strong>3. Write config</strong>: Write <code>memory/amg-check-pg-flex/config.md</code>:</p>
<pre><code class="language-markdown"># amg-check-pg-flex Configuration

User-specific values for the PostgreSQL Flexible Server health check skill.
This file is auto-generated on first run and can be edited manually.

Azure Monitor Datasource

  • **UID**: {discovered_uid}
  • **Name**: {discovered_name}

Subscription

- {subscription_id}
</code></pre>
<p><strong>4. Confirm</strong>: Show the resolved config and ask for confirmation before proceeding.</p>

推荐文章

更多
PHP时间戳与日期字符串相互转换方法详解

本文介绍PHP中时间数值(Unix时间戳)与日期字符串之间的相互转换方法。通过strtotime和date函数,实现将当前时间、指定日期转换为时间戳,以及将时间戳格式化为可读的日期时间字符串,并提供相关在线计算工具推荐。

2025.11.30 1,031
PHP日期转时间戳时区偏差怎么解决

在 PHP 中将日期字符串转换为时间戳时,若未显式指定时区,默认使用脚本配置的 date.timezone 或系统时区。当服务器时区与业务逻辑预期(如 UTC )不一致时,会产生偏差。解决核心是确保输入字符串携带明确时区信息,或在转换前统一设置时区上下文。

2026.10.24 1,029
PHP跨域配置:怎么安全地允许指定域名而非使用通配符

在 PHP 中安全地允许指定域名跨域,核心是解析请求头中的 Origin ,验证其是否在白名单内,然后动态设置 Access-Control-Allow-Origin 响应头。不要使用通配符 * ,也不要硬编码单一域名。

2025.03.29 1,017
JavaScript中利用replace结合正则实现replaceAll效果

JavaScript原生仅支持replace()进行单次或全局替换,缺乏类似Java的replaceAll()便捷方法。本文总结四种在JS中实现全量替换的方案:使用带g标志的正则、带gm标志的正则、扩展String原型以及split后join。通过对比代码示例,展示各方法的实现细节与适用场景,帮助开发者根据需求选择最优解。

2025.04.29 1,014
OpenAI的Jalapeno芯片未落地,教你分辨300兆瓦算力消息

OpenAI计划在SB Energy租赁的数据中心部署约300兆瓦自研Jalapeno推理芯片,但目前双方仍处于洽谈阶段,交易细节与上线时间表均未公布。本文带你按报道原文核实项目所处阶段,厘清芯片发布、电力功率与实际推理算力的边界,并将融资意向与签约、开工、投运节点分开追踪,避免误将规划容量计入现有算力。

2026.12.02 1,011
PHP实现基础文件上传:HTML表单与$_FILES处理流程

在 HTML 表单中设置 enctype="multipart/form-data" ,并在 PHP 后端通过 $_FILES 数组接收文件,调用 move_uploaded_file() 将临时文件移动到目标目录即可完成上传。

2026.09.07 1,011
Skill 文件

相关 Skill

更多
Alibabacloud Rds Postgresql Inspection Alibabacloud Rds Postgresql Inspection 批量健康检查阿里云RDS PostgreSQL实例,生成包含资源使用、告警、慢日志、长事务和复制等信息的详细HTML报告。
Claimable Postgres Claimable Postgres 通过 Neon 的 Claimable Postgres (neon.new) 即时创建临时 Postgres 数据库,无需登录、注册或信用卡,支持 REST API、CLI 等方式。
postgresql-skill postgresql-skill 使用psycopg2执行PostgreSQL数据库操作,列出表、描述模式、执行SQL查询。
Add Postgres-native vector retrieval to agent and RAG workflows with pgvector Add Postgres-native vector retrieval to agent and RAG workflows with pgvector 将嵌入向量存储在 Postgres 中的应用数据旁边,创建向量索引,并查询最近邻以进行语义搜索、RAG、推荐或代理内存检索。
MySQL to PostgreSQL Migration MySQL to PostgreSQL Migration 在将项目数据库层从MySQL迁移到PostgreSQL时使用此技能。覆盖SQL方言转换(MyBatis XML/原始SQL)和ORM配置等...