-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gafana errors after importing teslamate postgres database #3976
Comments
Yes, thats why they are stated in the docs.
As Postgres12 is outdated since years, we can not support such bug version jumps, but there had been succesful migrations in the past from other users, so it should be possible. Best ist to do the migration on old system, then import to new system.
https://docs.teslamate.org/docs/maintenance/upgrading_postgres |
Thank you for the prompt reply @JakobLichterfeld. If it's not too much trouble, could you please be so kind as to keep this ticket Open until there is some resolution? I spent a lot of hours troubleshooting and putting this ticket together, with all the details and logs, and it is very disconcerting to see it closed in a minute and without any resolution. Since teslamate is about 5 years old, other users here may have run into this or similar issues with DB upgrades & migrations, therefore someone may have solutions or ideas they can share, this is why I provide so much detail. This in turn will help the teslamate community, provided the ticket is not closed before an actual resolution... Now, just to recap: 1 - You said that the "Drop existing data and reinitialize" process is STILL needed even with importing a backup into a fresh/newly spun-up database, which is what I did, but it is good to know since that was not clear in the docs, as they only cover an in-place upgrade. 2 - Appreciate your great idea of me trying to 1st do an in-place upgrade directly on the Source/old host from postgres:12 to postgres:16 which I will do, and will report back here if it worked. 3 - If the Source upgrade-in-place is successful, I'll export/backup the upgraded Source teslamate postgres:16 database, and again import it into the freshly rebuilt Target host with clean postgres:16, after re-doing the "Drop existing data and reinitialize" process. Thank you. P.S. @DrMichael, also thank you for clarifying my last ticket #3968 prematurely closed was not related to Portainer and for the suggestion to use the service name with |
OK, @JakobLichterfeld and @DrMichael I have partial good news, we are closer to a solution: 1 - I managed to do an in-place postgres:12 to postgres:16 database upgrade on the Source host! 2 - I re-exported the now upgraded postgres:16 teslamate database data from the Source host and imported it into a fresh build of the Target host after it's own postgres:16 database first received the "Drop existing data and reinitialize" process. Sadly, while the Source upgrade was successful and that host and is now running postgres:16, the imported data on the Target host is again NOT being rendered correctly by Grafana! This is what I get in Grafana on the Target host Grafana logs on the Target host continue to include the
Some references online refer to not having DNS access from Grafana container, but I do:
AND nslookup successfuly...
However it is unclear why Grafana is trying to access "database" on 127.0.0.11:53 and how this can be fixed? Could this be some internal hardcoding in the postgres DB of the expected docker compose Now, as this is no longer a postgres old version issue, it is clearly something with postgres or Grafana, possibly related to the paths, or maybe docker compose service names, so I am hoping there is more I can try to get this fixed given we are so close... Maybe something in the Grafana config or something I can check or change in the backup file before importing it? Your patience and any additional help would be appreciated... Thank you. |
As expected it is not an issue with TeslaMate but with your new "target" system. Please provide docker-compose.yml without credentials and make sure to delete your postgres docker volume completely before the restore to get a clear starting state (as you messed around with it). |
Hello @JakobLichterfeld, This does indeed prove that an in-place teslamate postgres:12 to postgres:16 version upgrade works, which is great news for anyone with an older setup. However, as described from the start, the Target system uses one FQDN instead of two for the Source, so it is different. Adjusting teslamate to migrate from one configuration to the other should be trivial, especially since the manual details setups for both instances. Also, as described in detail above and per provided logs, the postgres:16 docker volume on the Target was deleted in full followed by being re-created and having the "Drop existing data and reinitialize" process applied, BEFORE the DB restore. HERE is the Source docker-compose.yml If any other details are needed, please just ask. I am hoping someone has a suggestion on how to fix this and allow the data imported into the Target from the Source to be made accessible by Grafana on the Target... Thank you. P.S. If I start the Target host with a fresh postgres:16 so not to loose new tesla API events, and once this issue is resolved I attempt to import the old/original data from the Source server (with same postgres:16 version DB), can I do so without loosing the new/previous up-to-date data in the database? Basically can one add teslamate backup data "on top" of existing data, rather than replace everything with the older backup? |
No. Would suggest you take your source system (which is hopefully complete) and load it to your target system and then shut down source.
See #3982 |
Thanks @cwanja ! So based on the link you referenced, the last issue me and others are seeing, the Grafana |
There is a lot of assumptions in that block of text. Anything Grafana focused is outside my purview. Can confirm TeslaMate with non-uBlock ad blockers running is not facing Grafana pop-ups. |
Correct @cwanja I further tested using a Private Safari window, and no Grafana error. Though I did notice discrepancies from the Source teslamate host to the Target host as can be seen below. Any idea why would the |
Wake the car up. |
Good call @cwanja Thank you. |
Glad you found the error in your docker-compose on your own. As assumed correctly, no TeslaMate issue at all |
Indeed @JakobLichterfeld, thank you for pointing me in the right direction and very glad this was just an internal configuration mismatch. Recommend having the My thanks again for everyone's help. |
Is there an existing issue for this?
What happened?
SOLVED! - SEE HERE: #3976 (comment)
Failed attempt to "move" (backup and restore) a full teslamate database between two different hosts (servers)!
The Source host was using CentOS 7 and an older postgres:12 database and was configured for separate FQDN's:
teslamate.example.com
&garfana.example.com
The Target host was setup with Ubuntu Server 22.04 and the newest postgres:16 database, as well as one FQDN with a subpath:
tm.example.com
&tm.example.com/grafana
Both hosts confirmed running latest Docker (v26.0.0 / v26.1.4) and Docker Compose (vv2.25.0 / v2.27.1) versions.
These are the steps taken with great care and with no errors occurred in the import process, only in Grafana when accessing the imported data:
A - Ensured teslamate on Source host was running properly and was recording data from the Tesla API.
B - Upgraded Source host teslamate from v1.29.1 to latest current version of v1.29.2
C - Exported Source host teslamate postgres:12 database into a file without any errors using:
docker compose exec -T database pg_dump -U teslamate teslamate > teslamate.bck
D - Deployed a fresh teslamate v1.29.2 environment on the Target host, using postgres:16 and single FQDN for Grafana as
tm.example.com/grafana
E - Prepared Target host for database import, as follows:
E1 - Stopped the new
teslamate
containerE2 - Accessed new postgres:16 DB and issued cleanup commands as per HERE (with no errors) using:
docker exec -i teslamate-postgres /bin/bash -c "PGPASSWORD=<TM_DB_PASS> psql --username teslamate teslamate" << .
Result was:
F - Imported database backup file copied to Target host (no errors) using:
docker exec -i teslamate-postgres /bin/bash -c "PGPASSWORD=<TM_DB_PASS> psql --username teslamate teslamate" < teslamate.bck
Results can be seen HERE
G - Started new
teslamate
container successfullyH - Accessed
tm.example.com
with no Tesla token prompt shown, so it means the original token imported correctly!I - Manually changed the access paths under teslamate's Settings Page for the cars
From:
To:
J - Attempted to access the Dashboards which opened up Grafana correctly and using the new path of
tm.example.com/grafana
, but there is no actual data shown only errors like this:Followed moments later by a Grafana "Failed to Fetch" Error notice:
K - Checked all containers log files and only errors were in the grafana container logs, see HERE
L - As a last resort used the pgAdmin manager tool to access the teslamate postgres:16 database, and confirmed the data imported correctly (cars were there, and so was old data), yet something is still broken!
QUESTIONS:
1 - Since the Target host had a fresh / newly deployed postgres:16 database, are the specific cleanup restore instructions outlined HERE to "Drop existing data and reinitialize" as per previous step "E2" still needed on a fresh setup before a backup file import is performed?
2 - Any other adjustments needed on the backup data file prior to importing, due to differences in the postgres:12 to postgres:16 versions?
3 - Before and After the database import, are there any other changes or database commands needed to properly display the historical data in Grafana without errors?
ANY IDEAS HOW TO FIX?
Thank you.
Expected Behavior
Grafana should render the imported data
Steps To Reproduce
See steps in description
Relevant log output
See logs links in description
Screenshots
see screenshots inline in description
Additional data
No response
Type of installation
Docker
Version
v1.29.2
The text was updated successfully, but these errors were encountered: