Skip to content

Commit 6438b70

Browse files
committed
Initial Version.
1 parent 7acacfb commit 6438b70

File tree

9 files changed

+31767
-0
lines changed

9 files changed

+31767
-0
lines changed
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
# Deploy NetApp Harvest on EC2
2+
3+
Harvest installation for monitoring Amazon FSxN using Promethues and Grafana stack, integrating AWS Secret Manager for FSxN credentials.
4+
5+
## Introduction
6+
7+
### What to Expect
8+
9+
Harvest installation will result in the following:
10+
* Install NetApp Harvest with the latest version on your EC2 instance.
11+
* Collecting metrics about your FSxNs and adding existing Grafana dashboards for better visualization.
12+
13+
### Prerequisites
14+
* A FSx for ONTAP running in the same VPC.
15+
* If not running an AWS based Linux, ensure that the `aws` command has been instealled and configured.
16+
17+
## Installation Steps
18+
19+
### 1. Create AWS Secret Manager with Username and Password for each FSxN
20+
21+
```sh
22+
aws secretsmanager create-secret --name <YOUR-SECRET-NAME> --secret-string '{"username":"fsxadmin","password":"<YOUR-PASSWORD>"}'
23+
```
24+
25+
### 2. Create Instance Profile with Permission to AWS Secret Manager and cloudwatch metrics
26+
27+
#### 2.1. Create Policy with Permissions to AWS Secret Manager
28+
29+
Edit the harvest-policy.json file found in this repo with the ARN of the AWS Secret Manager secret created above.
30+
31+
```sh
32+
POLICY_ARN=$(aws iam create-policy --policy-name harvest-policy --policy-document file://harvest-policy.json --query Policy.Arn --output text)
33+
```
34+
35+
#### 2.2. Create Instance Profile Role
36+
37+
```sh
38+
aws iam create-role --role-name HarvestRole --assume-role-policy-document file://trust-policy.json
39+
aws iam attach-role-policy --role-name HarvestRole --policy-arn $POLICY_ARN
40+
aws iam create-instance-profile --instance-profile-name HarvestProfile
41+
aws iam add-role-to-instance-profile --instance-profile-name HarvestProfile --role-name HarvestRole
42+
```
43+
44+
Note that the `trust-policy.json` file can be found in this repo.
45+
46+
### 3. Create EC2 Instance
47+
48+
We recommend using a `t2.xlarge` instance type with 20GB disk and attaching the instance profile.
49+
50+
If you already have an ec2 instance, you can use the following command to attach the instance profile:
51+
52+
```sh
53+
aws ec2 associate-iam-instance-profile --instance-id <INSTANCE-ID> --iam-instance-profile Arn=<Instance-Profile-ARN>,Name=HarvestProfile
54+
```
55+
You should get the instance profile ARN from step 2.2 above.
56+
57+
If your exiting ec2 instance already had an instance profile, then simply add the policy create in step 2.2 above.
58+
59+
### 4. Install Docker and Docker Compose
60+
61+
Use the following commands if you are running an Red Hat based Linux:
62+
```sh
63+
sudo yum install docker
64+
sudo curl -L https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-compose-plugin-2.6.0-3.el7.x86_64.rpm -o ./compose-plugin.rpm
65+
sudo yum install ./compose-plugin.rpm -y
66+
sudo systemctl start docker
67+
```
68+
If you aren't running a Red Hat based Linux, you can follow the instructions [here](https://docs.docker.com/engine/install/).
69+
70+
To confirm that docker has been installed correctly, run the following command:
71+
72+
```sh
73+
sudo docker run hello-world
74+
```
75+
76+
You should get output similar to the following:
77+
```
78+
Unable to find image 'hello-world:latest' locally
79+
latest: Pulling from library/hello-world
80+
e6590344b1a5: Pull complete
81+
Digest: sha256:bfbb0cc14f13f9ed1ae86abc2b9f11181dc50d779807ed3a3c5e55a6936dbdd5
82+
Status: Downloaded newer image for hello-world:latest
83+
84+
Hello from Docker!
85+
This message shows that your installation appears to be working correctly.
86+
87+
To generate this message, Docker took the following steps:
88+
1. The Docker client contacted the Docker daemon.
89+
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
90+
(amd64)
91+
3. The Docker daemon created a new container from that image which runs the
92+
executable that produces the output you are currently reading.
93+
4. The Docker daemon streamed that output to the Docker client, which sent it
94+
to your terminal.
95+
96+
To try something more ambitious, you can run an Ubuntu container with:
97+
$ docker run -it ubuntu bash
98+
99+
Share images, automate workflows, and more with a free Docker ID:
100+
https://hub.docker.com/
101+
102+
For more examples and ideas, visit:
103+
https://docs.docker.com/get-started/
104+
```
105+
### 5. Install Harvest on EC2
106+
107+
To install Harvest on your EC2 instance following the following steps:
108+
109+
#### 5.1. Generate Harvest Configuration File
110+
111+
Create `harvest.yml` file with your cluster details, below is an example with annotated comments. Modify as needed for your scenario:
112+
113+
```yaml
114+
Exporters:
115+
prometheus1:
116+
exporter: Prometheus
117+
port_range: 12990-14000
118+
add_meta_tags: false
119+
Defaults:
120+
use_insecure_tls: true
121+
Pollers:
122+
fsx01:
123+
datacenter: fsx
124+
addr: <FSxN_ip_1>
125+
collectors:
126+
- Rest
127+
- RestPerf
128+
- Ems
129+
exporters:
130+
- prometheus1
131+
credentials_script:
132+
path: /opt/fetch-credentails
133+
schedule: 3h
134+
timeout: 10s
135+
fsx02:
136+
datacenter: fsx
137+
addr: <FSxN_ip_2>
138+
collectors:
139+
- Rest
140+
- RestPerf
141+
- Ems
142+
exporters:
143+
- prometheus1
144+
credentials_script:
145+
path: /opt/fetch-credentails
146+
schedule: 3h
147+
timeout: 10s
148+
```
149+
150+
#### 5.2. Generate a Docker Compose from Harvest Configuration
151+
152+
Run the following command to generate a Docker Compose file from the Harvest configuration:
153+
154+
```sh
155+
docker run --rm \
156+
--env UID=$(id -u) --env GID=$(id -g) \
157+
--entrypoint "bin/harvest" \
158+
--volume "$(pwd):/opt/temp" \
159+
--volume "$(pwd)/harvest.yml:/opt/harvest/harvest.yml" \
160+
ghcr.io/netapp/harvest \
161+
generate docker full \
162+
--output harvest-compose.yml
163+
```
164+
165+
:warning:**NOTE** Ignore the command that it outputs used to start Harvest.
166+
167+
#### 5.3. Replace Harvest images in the harvest-compose.yml:
168+
169+
Replace the Harvest image that supports using AWS Secret Manager for FSxN credentials:
170+
171+
```yaml
172+
sed -i 's|ghcr.io/netapp/harvest:latest|ghcr.io/tlvdevops/harvest-fsx:latest|g' harvest-compose.yml
173+
```
174+
175+
#### 5.4. Add AWS Secret Manager Names to Docker Compose Environment Variables
176+
177+
`SECRET_NAME` and `AWS_REGION` are required for the credentials script.
178+
179+
```yaml
180+
services:
181+
fsx01:
182+
image: ghcr.io/tlvdevops/harvest-fsx:latest
183+
container_name: poller-fsx01
184+
restart: unless-stopped
185+
ports:
186+
- "12990:12990"
187+
command: '--poller fsx01 --promPort 12990 --config /opt/harvest.yml'
188+
volumes:
189+
- ./cert:/opt/harvest/cert
190+
- ./harvest.yml:/opt/harvest.yml
191+
- ./conf:/opt/harvest/conf
192+
environment:
193+
- SECRET_NAME=<your_secret_name>
194+
- AWS_REGION=<region_where_secret_resides>
195+
networks:
196+
- backend
197+
```
198+
#### 5.5. Download FSxN dashboards and import into Grafana container:
199+
The following commands will download the FSxN designed dashboards from this repo and replace the default Grafana dashboards with them:
200+
```yaml
201+
wget https://raw.githubusercontent.com/NetApp/FSx-ONTAP-samples-scripts/main/Monitoring/monitor_fsxn_with_grafana/fsx_dashboards.zip
202+
unzip fsx_dashboards.zip
203+
rm -rf grafana/dashboards
204+
mv dashboards grafana/dashboards
205+
```
206+
207+
#### 5.6. Configure Prometheus to use yet-another-exporter (yace) to gather AWS FSxN metrics
208+
AWS has useful metrics regarding the FSxN file system that ONTAP doesn't provide. Therefore, it is recommended to install
209+
an exporter that will expose these metrics. The following steps show how to install a recommended exporter.
210+
211+
##### 5.6.1 Create the yace configuration file.
212+
Use the text in the box below to create the configuration file named `yace-config.yaml`. Replace `<your_region>`, in both places, with the region where your FSxN resides:
213+
214+
```yaml
215+
apiVersion: v1alpha1
216+
sts-region: <your_region>
217+
discovery:
218+
jobs:
219+
- type: AWS/FSx
220+
regions: [<your_region>]
221+
period: 300
222+
length: 300
223+
metrics:
224+
- name: DiskReadOperations
225+
statistics: [Average]
226+
- name: DiskWriteOperations
227+
statistics: [Average]
228+
- name: DiskReadBytes
229+
statistics: [Average]
230+
- name: DiskWriteBytes
231+
statistics: [Average]
232+
- name: DiskIopsUtilization
233+
statistics: [Average]
234+
- name: NetworkThroughputUtilization
235+
statistics: [Average]
236+
- name: FileServerDiskThroughputUtilization
237+
statistics: [Average]
238+
239+
```
240+
241+
##### 5.6.2 Add Yet-Another-Exporter to harvest-compose.yaml
242+
243+
Copy the following to the end of the `harvest-compose.yml` file:
244+
```yaml
245+
yace:
246+
image: quay.io/prometheuscommunity/yet-another-cloudwatch-exporter:latest
247+
container_name: yace
248+
restart: always
249+
expose:
250+
- 8080
251+
volumes:
252+
- ./yace-config.yaml:/tmp/config.yml
253+
- $HOME/.aws:/exporter/.aws:ro
254+
command:
255+
- -listen-address=:8080
256+
- -config.file=/tmp/config.yml
257+
networks:
258+
- backend
259+
```
260+
261+
##### 5.6.3. Add Yet-Another-Exporter target to prometheus.yml:
262+
```yaml
263+
sudo sed -i -e "\$a\- job_name: 'yace'" -e '$a\ static_configs:' -e "\$a\ - targets: ['yace:8080']" container/prometheus/prometheus.yml
264+
```
265+
266+
##### 6. Bring Everything Up
267+
268+
```sh
269+
sudo docker compose -f prom-stack.yml -f harvest-compose.yml up -d --remove-orphans
270+
```
271+
272+
After bringing up the prom-stack.yml compose file, you can access Grafana at
273+
http://IP_OF_GRAFANA:3000.
274+
275+
You will be prompted to create a new password the first time you log in. Grafana's default credentials are:
276+
```
277+
username: admin
278+
password: admin
279+
```

0 commit comments

Comments
 (0)