Skip to content

Commit

Permalink
feat: first basic conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Picred committed Apr 13, 2024
1 parent 4443d01 commit 1308fc1
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# name: CI

# on:
# push:
# branches: [main]
# paths-ignore:
# - "README.md"
# - "doc/**"
# pull_request:
# branches: [main]
# paths-ignore:
# - "README.md"
# - "doc/**"

# jobs:
# test:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - name: Set up Python 3.10
# uses: actions/setup-python@v2
# with:
# python-version: "3.10"
# - name: Install dependencies for requirements and testing
# run: |
# python -m pip install --upgrade pip
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
# - name: Lint with pylint
# run: |
# pylint src/*
# - name: Create token.txt
# run: |
# echo ${{ secrets.TOKEN }} > token.txt
# - name: Test with pytest
# run: |
# pytest --cov=src --cov=main tests/ --cov-fail-under=75
# - name: Delete token.txt
# run: |
# rm -f token.txt
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

.idea/
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
# air-flow-monitor
Real-time air quality tracking software

# Prerequisites
To use the Air-Flow Monitor, you should be familiar with the following:
- [Docker](https://www.docker.com/)
- [Python](https://www.python.org/)
- API key (dipende dal provider scelto)


## Logstash
```bash
cd logstash
docker build . --tag tap:logstash
docker run --rm -it --hostname="logstash" -v $PWD/pipeline/httpoller.conf:/usr/share/logstash/pipeline/logstash.conf -e XPACK_MONITORING_ENABLED=false docker.elastic.co/logstash/logstash:8.13.0
```
10 changes: 10 additions & 0 deletions logstash/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM docker.elastic.co/logstash/logstash:8.13.0

# Add your logstash plugins setup here
RUN logstash-plugin install logstash-filter-sentimentalizer

# to build with
# docker build . --tag tap:logstash
# and run with
# docker run --rm -it --hostname="logstash" -v $PWD/pipeline/echostash.conf:/usr/share/logstash/pipeline/logstash.conf -e XPACK_MONITORING_ENABLED=false docker.elastic.co/logstash/logstash:8.13.0
# make sure that pipeline dir with proper conf is there%
59 changes: 59 additions & 0 deletions logstash/pipeline/nearest_city.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
input {
http_poller {
urls => {
get_countries => {
method => get
url => "http://api.airvisual.com/v2/nearest_city?key=0e72cb61-87b6-4ab4-b422-0886e1305ac6"
headers => {
"Content-Type" => "application/json"
# <add_authorization_or_password>
}
}
}
request_timeout => 60
codec => "json"
type => "Http_poller"
schedule => { "every" => "1h" }
}
}

filter {
json {
source => "event.original"
target => "parsed_data"
}

mutate {
remove_field => ["event", "status", "@version"] # Rimuove i campi non necessari
}

# Rinomina i campi all'interno della struttura "data" per renderli più leggibili
mutate {
rename => {
"[data][current][weather][ic]" => "weather_icon"
"[data][current][weather][pr]" => "pressure"
"[data][current][weather][tp]" => "temperature"
"[data][current][weather][ws]" => "wind_speed"
"[data][current][weather][hu]" => "humidity"
"[data][current][weather][wd]" => "wind_direction"
"[data][current][weather][ts]" => "weather_timestamp"
"[data][current][pollution][maincn]" => "pollution_maincn"
"[data][current][pollution][aqius]" => "pollution_aqius"
"[data][current][pollution][mainus]" => "pollution_mainus"
"[data][current][pollution][aqicn]" => "pollution_aqicn"
"[data][current][pollution][ts]" => "pollution_timestamp"
}
}

mutate {
remove_field => ["[data][current][weather]", "[data][current][pollution]"]
}
}

output {
# file{
# path => "tmp/messages"
# }

stdout {}
}

0 comments on commit 1308fc1

Please sign in to comment.