Skip to content

Commit

Permalink
Token access tweaks (#24)
Browse files Browse the repository at this point in the history
* Make sure the type is consistent on connect_time tag

* Dont raise if failing to create the org/bucket.

* Bump workflow versions
  • Loading branch information
GilbN authored Sep 7, 2024
1 parent bfb5a6f commit 25b31b8
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ Add the ones that differ on your system.
| INFLUXDB_V2_BATCH_SIZE | 100 | Optional, defaults to 10. |
| INFLUXDB_V2_FLUSH_INTERVAL | 30000 | Optional, defaults to 15000. How often in milliseconds to write a batch |

#### INFLUXDB_V2_TOKEN

If the organization or bucket does not exist, it will try and create them with the token.

> [!NOTE]
> The minimim level of rights needed is write access to the bucket.
### MaxMind Geolite2

Default download location is `/config/geoip2db/GeoLite2-City.mmdb`
Expand Down
4 changes: 0 additions & 4 deletions geoip2influx/influxv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ def create_bucket(self) -> None:
self.logger.info("Bucket %s created.", self.bucket)
except Exception:
self.logger.exception("Error creating bucket %s.", self.bucket)
raise

def bucket_exists(self) -> bool:
"""Check if the bucket exists."""
Expand All @@ -176,7 +175,6 @@ def bucket_exists(self) -> bool:
return False
except Exception:
self.logger.exception("Error checking bucket %s.", self.bucket)
raise

def create_org(self) -> None:
"""Create the organization if it does not exist."""
Expand All @@ -189,7 +187,6 @@ def create_org(self) -> None:
self.logger.info("Organization %s created.", self.org)
except Exception:
self.logger.exception("Error creating organization %s.", self.org)
raise

def org_exists(self) -> bool:
"""Check if the organization exists."""
Expand All @@ -202,4 +199,3 @@ def org_exists(self) -> bool:
return False
except Exception:
self.logger.exception("Error checking organization %s.", self.org)
raise
2 changes: 1 addition & 1 deletion geoip2influx/logparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def create_log_metrics(self, log_data:re.Match[str], ip:str) -> list[dict]:
try:
log_data_fields['connect_time'] = float(datadict['connect_time']) if datadict['connect_time'] != '-' else 0.0
except ValueError:
log_data_fields['connect_time'] = str(datadict['connect_time'])
log_data_fields['connect_time'] = 0.0
log_data_tags['ip'] = datadict['ipaddress']
log_data_tags['datetime'] = datetime.strptime(datadict['dateandtime'], '%d/%b/%Y:%H:%M:%S %z')
log_data_tags['remote_user'] = datadict['remote_user']
Expand Down

0 comments on commit 25b31b8

Please sign in to comment.