marinebon / mbon-dashboard-server

server software for MBON early alert dashboard using Docker
1 stars 2 forks source link

influx not accepting data #32

Closed 7yl4r closed 3 years ago

7yl4r commented 3 years ago

influxdb not taking data currently. failing in airflow and at manual submission (http://35.209.104.85:5000/submit/sat_image_extraction). This might just be a firewall thing.

mbon_data_uploader
v

HTTPException
500

Description:
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

Stack trace:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2070, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1513, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1499, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/opt/mbon_data_uploader/mbon_data_uploader/__init__.py", line 42, in sat_image_extraction
    return get_form_and_post_upload(
  File "/opt/mbon_data_uploader/mbon_data_uploader/__init__.py", line 123, in get_form_and_post_upload
    return validate_and_handle_file(
  File "/opt/mbon_data_uploader/mbon_data_uploader/__init__.py", line 110, in validate_and_handle_file
    file_handler(filepath, request.form)
  File "/opt/mbon_data_uploader/mbon_data_uploader/handle_csv_file.py", line 40, in handle_csv_file
    subprocess.run([
  File "/usr/local/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['export_csv_to_influx', '--csv', '/tmp/fgb-_-EXT_TS_MODA-_-OC-_-FGBdbv2_ABI_TS_MODA_daily_COAST1.csv', '--dbname', 'fwc_coral_disease', '--measurement', 'rs_oc_chlor', '--field_columns', 'mean,climatology,anomaly', '--tag_columns', 'location', '--force_insert_even_csv_no_update', 'True', '--server', 'localhost:8086', '--time_column', 'Time']' returned non-zero exit status 1.

Subprocess error details:
command:
return code:

output:
None

stdout:
None

stderr:
None

To report this error please open a "new issue" in the code repository's issue tracker and include the details above.
7yl4r commented 3 years ago

I am able to read & write to influx from the docker hypervisor:

[tylarmurray@fgb-dashboard ~]$ curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=fwc_coral_disease" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region
\"='us-west'"
{
    "results": [
        {
            "statement_id": 0
        }
    ]
}
[tylarmurray@fgb-dashboard ~]$ curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE my_test_db"
HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: 8d565056-e7e4-11eb-800b-0242ac140009
X-Influxdb-Build: OSS
X-Influxdb-Version: 1.8.4
X-Request-Id: 8d565056-e7e4-11eb-800b-0242ac140009
Date: Sun, 18 Jul 2021 16:23:57 GMT
Transfer-Encoding: chunked
{"results":[{"statement_id":0}]}
[tylarmurray@fgb-dashboard ~]$ curl -G 'http://localhost:8086/query?pretty=true' --data-urlencode "db=my_test_db" --data-urlencode "q=SELECT \"value\" FROM \"cpu_load_short\" WHERE \"region\"='us-
west'"
{
    "results": [
        {
            "statement_id": 0
        }
    ]
}

and read from my PC:

[tylar@tylar-pc ~]$ curl -G 'http://35.209.104.85:8086/query?pretty=true' --data-urlencode "db=my_test_db" --data-urlencode "q=SELECT \"value\" FROM \"cpu       _load_short\" WHERE \"region\"='us-west'"
{
    "results": [
        {
            "statement_id": 0
        }
    ]
}

and read from the mbon_docker_uploader container:

[tylarmurray@fgb-dashboard ~]$ docker exec -it mbon_data_uploader curl -G 'http://35.209.104.85:8086/query?pretty=true' --data-urlencode "db=my_test_db" --data-urlencode "q=SELECT \"value\" FROM \
"cpu_load_short\" WHERE \"region\"='us-west'"
{
    "results": [
        {
            "statement_id": 0
        }
    ]
}
7yl4r commented 3 years ago

Looking at the command from the error in the OP I see localhost where we should instead have the server public IP:

export_csv_to_influx --csv /tmp/fgb-_-EXT_TS_MODA-_-OC-_-FGBdbv2_ABI_TS_MODA_daily_COAST1.csv --dbname fwc_coral_disease --measurement rs_oc_chlor --field_columns mean,climatology,anomaly --tag_columns location --force_insert_even_csv_no_update True --server localhost:8086 --time_column Time

This is of course throwing a ConnectionRefusedError. I wish I could that information into the html 500 response instead of the generic subprocess failure. Not sure why the Subprocess error details: section is all Nones. 😞

7yl4r commented 3 years ago

Looks like a missing environment var:

[tylarmurray@fgb-dashboard ~]$ docker exec -it mbon_data_uploader echo $INFLUXDB_HOSTNAME

buuuuut also that environment var isn't coming back empty in the script... it is working as set in the docker-compose.yml. Curious that the above command isn't showing that but that's not the issue we are exploring today.