西维蜀黍

【Prometheus】Metric Name

Metric Names

A metric name…

  • …must comply with the data model for valid characters.
  • …should have a (single-word) application prefix relevant to the domain the metric belongs to. The prefix is sometimes referred to as namespace by client libraries. For metrics specific to an application, the prefix is usually the application name itself. Sometimes, however, metrics are more generic, like standardized metrics exported by client libraries. Examples:
    • prometheus_notifications_total (specific to the Prometheus server)
    • process_cpu_seconds_total (exported by many client libraries)
    • http_request_duration_seconds` (for all HTTP requests)
  • …must have a single unit (i.e. do not mix seconds with milliseconds, or seconds with bytes).
  • …should use base units (e.g. seconds, bytes, meters - not milliseconds, megabytes, kilometers).
  • …should have a suffix describing the unit, in plural form. Note that an accumulating count has total as a suffix, in addition to the unit if applicable.
    • http_request_duration_**seconds**
    • node_memory_usage_**bytes**
    • http_requests_**total** (for a unit-less accumulating count)
    • process_cpu_**seconds_total** (for an accumulating count with unit)
    • foobar_build**_info** (for a pseudo-metric that provides metadata about the running binary)
  • …should represent the same logical thing-being-measured across all label dimensions.
    • request duration
    • bytes of data transfer
    • instantaneous resource usage as a percentage

As a rule of thumb, either the sum() or the avg() over all dimensions of a given metric should be meaningful (though not necessarily useful). If it is not meaningful, split the data up into multiple metrics. For example, having the capacity of various queues in one metric is good, while mixing the capacity of a queue with the current number of elements in the queue is not.

  ...


【Engineering】Monitoring System

Context

While there is a certain intellectual satisfaction to be had by getting a system just right, the purpose of monitoring is to help you run whatever it is that you’re monitoring. That could be a website used directly by your customers, a backend only used internally, or even industrial systems. Fundamentally your customers don’t care how well your monitoring is working, they care how well the services they’re interacting with function. Part of you providing that service should involve some level of monitoring (in the broadest sense of the word) to ensure that things aren’t going badly wrong, but that’s just one part of providing the service.

  ...


【Golang】源码 - json - Marshal

func Marshal(v interface{}) ([]byte, error)

Marshal returns the JSON encoding of v.

Marshal traverses the value v recursively. If an encountered value implements the Marshaler interface and is not a nil pointer, Marshal calls its MarshalJSON method to produce JSON. If no MarshalJSON method is present but the value implements encoding.TextMarshaler instead, Marshal calls its MarshalText method and encodes the result as a JSON string. The nil pointer exception is not strictly necessary but mimics a similar, necessary exception in the behavior of UnmarshalJSON.

  ...


【Golang】关键字 - switch

switch

A switch statement is a shorter way to write a sequence of if - else statements. It runs the first case whose value is equal to the condition expression.

Go’s switch is like the one in C, C++, Java, JavaScript, and PHP, except that Go only runs the selected case, not all the cases that follow. In effect, the break statement that is needed at the end of each case in those languages is provided automatically in Go. Another important difference is that Go’s switch cases need not be constants, and the values involved need not be integers.

  ...


【Hackintosh】知识

ACPI

ACPI 是 Hewlett-Packard, Intel, Microsoft, Phoenix 和 Toshiba 共同制定的一个开放的行业规范。是 The Advanced Configuration and Power Interface 的缩写,也就是“电源管理模式和配置管理的接口规范”。从名字可以看出主要是“电源管理”和“配置管理”。是 BIOS 的一个高级功能模块。

它帮助操作系统合理控制和分配计算机硬件设备的电量,有 了ACPI,操作系统可以根据设备实际情况,根据需要把不同的硬件设备关闭。如Win7或者Win8系统,系统睡眠时,系统把当前信息储存在内存中,只保留内存等几个关键部件硬件的通电,使计算机处在高度节电状态。当然这只是它功能中的很少一部分。

它主要涵盖的功能包括:

  1. System power management(系统电源管理)
  2. Device power management(设备电源管理)
  3. Processor power management(处理器电源管理)
  4. Device and processor performance management(设备及处理器性能管理)
  5. Configuration / Plug and Play(配置/即插即用)
  6. System Events(系统事件)
  7. Battery management(电池管理)
  8. Thermal management(温度管理)
  9. Embedded Controller(嵌入式控制器)
  10. SMBus Controller(SMBus控制器)

在计算机应用平台,ACPI 越来越重要。ACPI由很多表组成,包括:RSDP,SDTH,RSDT,FADT,FACS,DSDTSSDT,MADT,SBST,XSDT,ECDT,SLIT,SRAT。其中DSDT就是它的一个重要的描述表。

  ...