# Monitoring Setup

## Overview <a href="#overview" id="overview"></a>

The Klaytn team provides a site for monitoring the Klaytn CCN at <http://cypress.klaytn.net:3000>. The `telegraf` monitoring agent is installed in each CN/PN of the CC to collect metrics and send them to the monitoring server. Once installed, you may visit the monitoring site to view the metrics of the Klaytn CCs.

The installation process is as follows:

1. Install `telegraf` in the CN/PNs
2. Configure `telegraf`
3. Start `telegraf`

## Telegraf Installation <a href="#telegraf-installation" id="telegraf-installation"></a>

Telegraf Installation Guide (Amazon Linux 2 users, see below): <https://docs.influxdata.com/telegraf/latest/introduction/installation/>

**Note for Amazon Linux 2**

To install Telegraph on Amazon Linux 2, you may use InfluxData's RHEL 7 yum repo as follows:

```
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL 7
baseurl = https://repos.influxdata.com/rhel/7/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
```

## Telegraf Setup <a href="#telegraf-setup" id="telegraf-setup"></a>

### Enable monitoring in kcnd/kpnd <a href="#enable-monitoring-in-kcnd-kpnd" id="enable-monitoring-in-kcnd-kpnd"></a>

/etc/kcnd/conf/kcnd.conf

```
...
METRICS=1
PROMETHEUS=1
...
```

**Check**

You may confirm that the above two options are enabled by checking that port 61001 is open.

```
$ netstat -ntap | grep 61001
tcp        0      0 :::61001        :::*       LISTEN      8989/kcn
```

**Configure Telegraf service**

Copy the following file to the `telegraf` configuration directory (`/etc/telegraf/telegraf.d/`), and edit `nodetype`, `instance`, and `hostname` appropriately for each node:

```
[global_tags]
  # Change "cn" to "pn" for PN installation
  nodetype = "cn"

  # The CN/PN name (e.g. `example-cn`, `example-pn`)
  instance = "<hostname>"

[agent]
  # The CN/PN name (e.g. `example-cn`, `example-pn`)
  hostname = "<hostname>"

[[outputs.influxdb]]
  urls = [ "http://localhost:" ]
  database = "klaytn_cypress"

[[inputs.prometheus]]
  urls = [ "http://localhost:61001/metrics" ]
```

Change the following in `/etc/telegraf/telegraf.conf`:

* Comment out the `[[outputs.influxdb]]` section

**Start Telegraf**

```
$ systemctl restart telegraf
```

## Grafana <a href="#grafana" id="grafana"></a>

If each CN/PN has the above configuration and agent, you can check the metrics at the following URL:

<http://cypress.klaytn.net:3000>

As a CC operator, you may request an account by providing your company name and email address in the Slack channel. Please note that only CC operators are allowed to request a Grafana account.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://archive-docs.klaytn.foundation/content/installation-guide/deployment/core-cell/monitoring-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
