Shumoku Docs

ドキュメントを検索

共通文書と現行公開版

検索を読み込み中…

English

@shumoku/core · 0.4.0 · function

flattenObject

ソース

APIの説明は英語のcanonical sourceを表示しています。

Flatten an arbitrary upstream record into `DiscoveredMetric[]` for the plugin "All metrics" passthrough panel. This is the generic dumper every `HostsCapable` plugin should use instead of hand-enumerating fields (which is how zabbix ended up coercing every value to a number and dropping categorical attributes). Walk the object: - object children join into the metric name with `_` (`{ a: { b: 1 } }` with prefix `p` → `p_a_b`), - array-of-primitives emits a `<name>_count`, - array-of-objects emits a `<name>_count` then expands each element with a `<key>_index` label, - null / undefined / empty-string / non-finite leaves are skipped as noise. Lifted verbatim (behavior-preserving) from the aruba-instant-on plugin, which had the only correct generic implementation.

flattenObject(obj: unknown, prefix: string, labels?: Record<string, string>): DiscoveredMetric[]

パラメーター

名前 説明 既定値
obj unknown 追加説明はありません。
prefix string 追加説明はありません。
labels Record<string, string> 追加説明はありません。 {}

戻り値

DiscoveredMetric[]

libs/@shumoku/core/src/plugin-kit/metrics-flatten.ts:24