Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install telegraf using go monitoring scheme

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "how to install telegraf using go monitoring scheme". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Telegraf learning

Telegraf the whole package is very large, in this program only the statsd plug-in part of the modification, so more specific needs to learn according to their own needs, if you only use this program can be skipped.

Start

Telegraf is a plug-in-driven server agent that collects and reports metrics and is the first part of the TICK stack. Telegraf has plug-ins that extract metrics directly from the systems it runs, extract metrics from third-party API, and even monitor metrics through statsd and Kafka consumer services. It also has an output plug-in that sends metrics to a variety of other data stores, services and message queues, including InfluxDB,Graphite,OpenTSDB,Datadog,Librato,Kafka,MQTT,NSQ, and so on.

download

Download

Installation

Mac version

Installation

Brew update brew install telegraf

Start telegraf the next time you log in

Ln-sfv / usr/local/opt/telegraf/*.plist ~ / Library/LaunchAgents

Load telegraf

Launchctl load ~ / Library/LaunchAgents/homebrew.mxcl.telegraf.plist

If you don't use launchctl, just start it with the following command

Telegraf-config / usr/local/etc/telegraf.conflinux profile location / etc/telegraf/telegraf.conf

Start

Sudo service telegraf startsystemctl start telegraf network configuration

Telegraf provides multiple service input plug-ins, which may require custom ports.

Configuration file: / etc/telegraf/telegraf.conf

NTP

Telegraf uses the UTC local time of the host to assign a timestamp to the data. Time between hosts is synchronized using the Network time Protocol (NTP); if the host's clock is out of sync with NTP, the timestamp of the data may be inaccurate.

Config

Create a configuration file using the default input and output plug-ins.

Telegraf config > telegraf.conf

Create a profile with specific inputs and outputs

Telegraf-- input-filter [:]-- output-filter [:] config > telegraf.conf example

Before starting the Telegraf server, you need to edit and / or create an initial configuration that specifies the required inputs (where the metrics come from) and outputs (where the metrics are located).

Here, we will generate a configuration file, using the-input-filter flag to specify the desired input and the-output-filter flag to specify the desired output.

In the following example, we create a configuration file called telegraf.conf that contains two inputs: one reads a metric about system cpu usage (cpu) and the other reads a metric about system memory usage (mem). We specify InfluxDB as the desired output.

Getting started with telegraf-sample-config-input-filter cpu:mem-output-filter influxdb > telegraf.conf

Once Telegraf is up and running, it starts collecting data and writing it to the desired output.

We will show what the cpu and mem data look like in InfluxDB below.

Influxdb View measurements

> SHOW MEASUREMENTSname: measurements-namecpumem

Check the field keys in the

> SHOW FIELD KEYSname: cpu-fieldKey fieldTypeusage_guest floatusage_guest_nice floatusage_idle floatusage_iowait floatusage_irq floatusage_nice floatusage_softirq floatusage_steal floatusage_system Floatusage_user floatname: mem-fieldKey fieldTypeactive integeravailable integeravailable_percent floatbuffered integercached integerfree integerinactive Integertotal integerused integerused_percent float

Select a data sample field usage_idle in cpu_usage_idle:

> SELECT usage_idle FROM cpu WHERE cpu = 'cpu-total' LIMIT 5name: cpu-time usage_idle2016-01-16T00:03:00Z 97.561890472618162016-01-16T00:03:10Z 97.763059235191212016-01-16T00:03:20Z 97.325334333208352016-01-16T00:03:30Z 95.688577855536112016-01-16T00:03:40Z 98.63715928982245

Note that the timestamp occurs at ten-rounded intervals (that is, 00 magnificent 14), and so on-this is a configurable setting.

Conceptual indicator metrics

Telegraf metrics are internal representations used to model data during processing. These metrics are very based on InfluxDB's data model and contain four main components:

Measurement name metric name: description and namespace of the metric. Tags tags: key / value string pairs, usually used to identify metrics. Fields field: a key / value pair typed, usually containing metric data. Timestamp timestamp: the date and time associated with the field.

This metric type exists only in memory and must be converted to a concrete representation before it can be transferred or viewed.

Telegraf provides an output data format (also known as a serializer) for these transformations.

The default serializer for Telegraf is converted to the InfluxDB line protocol, which provides high performance and one-to-one direct mapping of Telegraf metrics.

Aggregator and processor plug-in ┌─┐│ ││ CPU │───┐│ │ │└─┘ │ │┌─┐ │ ┌─── ─┐│ │ ││ Memory │───┤ ┌──▶│ InfluxDB ││ │ │ │ │ │└─┘ │ ┌─┐ ┌─┐ │ └─┘ │ │ Aggregate │ │┌─ ────┐ │ │ Process │ │-mean │ │ ┌─┐│-transform │ │-quantiles ││ MySQL │───┼──▶ │-decorate-min/max ──▶│ File ││-filter │ │-count │└─┘ │ └─┘ │ └─┘ └─┘ │┌─┐ │ │ ┌─┐│ │ │ │ │ ││ SNMP │───┤ └──▶│ Kafka ││ │ │└─┘ │ └─┘ │┌─┐ ││ │ ││ Docker │───┘│ │└─┘

The processor plug-in (Processor plugins) processes metrics as it passes and emits results immediately based on the values they process. For example, this could be printing all metrics or adding tags to all passed metrics.

Aggregators (Aggregator plugins) are usually used to issue new aggregation metrics, such as running average, minimum, maximum, quantile, or standard deviation. Therefore, all aggregator plug-ins are configured with periods. The period is the size of the measurement window represented by each aggregation. In other words, the aggregate metric issued will be the aggregate value of the past period of seconds. Because many users only care about their aggregations rather than the metrics for each collection, there is also a drop_original parameter that tells Telegraf to emit only aggregations rather than the original metrics.

Note: because the aggregator plug-in aggregates metrics only within its period, historical data is not supported. In other words, if your metric timestamp exceeds the past time period of now ()-period, it will not be summarized.

Glossary agent

The agent is the core part of Telegraf that collects metrics from declared input plug-ins and sends metrics to declared output plug-ins based on a given configuration enabled plug-in.

Aggregator plugin

The Aggregator plug-in receives the original metrics from the input plug-in and creates aggregate metrics from it. The aggregate metric is then passed to the configured output plug-in.

Batch size batch size

The Telegraf agent sends metrics in batches to the output plug-in instead of sending them separately. The batch size controls the size of each write batch that Telegraf sends to the output plug-in.

Collection interval collection interval

The default global interval for collecting data from each input plug-in. The configuration of each input plug-in can override the collection interval.

Collection jitter collection jitter

Collection jitter is used to prevent each input plug-in from collecting metrics at the same time, which may have a measurable impact on the system. For each collection interval, each input plug-in sleeps for a random period of time between zero and collection jitter before collecting metrics.

Flush interval refresh interval

The global interval that refreshes data from each output plug-in to its destination. This value should not be set below the collection interval.

Input plugin input plug-in

The input plug-in actively collects metrics and delivers them to the core agent, where aggregators, processors, and output plug-ins can operate on metrics. To activate the input plug-in, you need to enable and configure it in the configuration file of Telegraf.

Metric buffer metric buffer

When writing to the output plug-in fails, the metric buffer caches individual metrics. Telegraf will attempt to flush the buffer after successfully writing the output. When this buffer fills up, the oldest metric is deleted first.

Output plugin output plug-in

The output plug-in passes metrics to the target of its configuration. To activate the output plug-in, you need to enable and configure it in the configuration file of Telegraf.

Precision precision

The precision configuration setting determines how much timestamp precision is retained from the points received by the input plug-in. All incoming timestamps are truncated to the given precision. Telegraf then fills the truncated timestamp with zeros to create a nanosecond timest the output plug-in will issue a timestamp in nanoseconds. The effective precision is ns,us or μ s Ms and s.

For example, if the precision is set to ms, the nanosecond timestamp 1480000000123456789 will be truncated to 1480000000123 with millisecond precision, and then filled with zeros to generate a new, less accurate nanosecond timestamp 1480000000123000000. The output plug-in does not change the timestamp further. The input plug-in for the service ignores the precision setting.

Processor plugin processor plug-in

The processor plug-in converts, modifies and / or filters the metrics collected by the input plug-in and passes the converted metrics to the output plug-in.

Service input plugin service input plug-in

The service input plug-in is an input plug-in that runs in passive collection mode while the Telegraf agent is running. They listen for known protocol inputs on sockets or apply their own logic to ingested metrics before providing them to the Telegraf agent.

Plug-in input plug-in

The Telegraf input plug-in is used with the InfluxData time series platform to collect metrics from systems, services, or third-party API. All metrics are collected from the input that you enabled and configured in the configuration file.

View the usage instructions for each service input by running telegraf-- usage.

Supported Telegraf input plug-in Telegraf input plugins

Output plug-in

Telegraf allows the user to specify multiple output receivers in the configuration file.

Supported Telegraf output plug-in Telegraf output plugins

Aggregator plug-in BasicStats

Plug-in ID: basicstats

The BasicStats aggregator plug-in gives count,max,min,mean,s2 (variance), and stdev is used for a set of values, each cycle second of luminous aggregation

Histogram histogram

Plug-in ID: histogram

The histogram aggregator plug-in creates a histogram of counts of field values within the range included.

Values added to buckets are also added to larger buckets in the distribution. This creates a cumulative histogram.

Like other Telegraf aggregator plug-ins, metrics are issued every second. However, bucket counts are not reset between periods of time, and will not be strictly increased while Telegraf is running.

MINMAX

Plug-in ID: minmax

In the Minimax aggregator plug-in aggregators min and max it sees the value of each field, and the emission aggregates each cycle second.

ValueCounter

Plug-in ID: valuecounter

The ValueCounter aggregation plug-in calculates values that occur in the field and emits counters once "during" seconds.

The use case for the ValueCounter aggregator plug-in is when you use the Logparser input plug-in to process the HTTP access log and want to calculate the HTTP status code.

You must use the fields configuration directive to configure the fields to count. If no fields are provided, the plug-in does not calculate any fields. The result is issued as a field in the format originalfieldname_fieldvalue = count.

ValueCounter can only be in the field of type int,bool or string. Deleting floating fields to prevent too many fields from being created.

Processor plug-in

Telegraf processor plugins

This is the end of the content of "how to install telegraf using go monitoring solution". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report