Skip to content
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

Invaps invalid Json Path #2

Open
Xtreme89 opened this issue Jan 31, 2023 · 8 comments
Open

Invaps invalid Json Path #2

Xtreme89 opened this issue Jan 31, 2023 · 8 comments
Assignees

Comments

@Xtreme89
Copy link

Hallo,

Infos zur Konstellation:

Raspberry Pi -> Invafetch sendet an an einen externen Server die Daten in die MYSQL DB

Auf dem Ubuntu Server 18.04 läuft eine Docker Instanz mit Grafana,Prometheus,MYSQL,Adminer, Invaps

Invaps selber sendet komische Fehler Meldungen in den Logs

docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 in recordcurrentValues again with last values
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesBatteryLast Error 3143: Invalid JSON path expression. The error is around character position 23.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalLast Error 3143: Invalid JSON path expression. The error is around character position 15.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetStatisticEnergyFlowLast Error 3143: Invalid JSON path expression. The error is around character position 26.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 in recordCurrentValues again
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocal Error 3143: Invalid JSON path expression. The error is around character position 15.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalBattery Error 3143: Invalid JSON path expression. The error is around character position 23.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalAc Error 3143: Invalid JSON path expression. The error is around character position 18.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Database problem in GetDevicesLocal: Error 3143: Invalid JSON path expression. The error is around character position 26.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalPowermeter Error 3143: Invalid JSON path expression. The error is around character position 26.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalPv1 Error 3143: Invalid JSON path expression. The error is around character position 19.
docker-monitoring-stack-gpnc-invaps-1  | 2023/01/31 08:28:28 Error in calling db.GetDevicesLocalPv2 Error 3143: Invalid JSON path expression. The error is around character position 19.
@geschke
Copy link
Owner

geschke commented Jan 31, 2023

Hallo!

Da Du explizit MySQL erwähnst, vermute ich dabei das Problem. Welche Version von MySQL wird genutzt? Laut Doku ist die betreffende Funktion JSON_VALUE() erst ab MySQL 8.0.21 verfügbar, wobei ich auch dazu die Kompatibilität nicht getestet habe, da sich die invafetch- und invaps-Tools bislang auf MariaDB stützen (wie auch in der Doku angegeben).
Ab MySQL 8.0.21 sollte es ok sein, aber wie erwähnt - ohne Gewähr, ich werde es mir aber auch gerne ansehen und mit MySQL statt MariaDB testen und ggf. anpassen.

Falls es das nicht sein sollte, wären ein paar Datensätze aus der solardata-Datenbank hilfreich, damit ich mir die Inhalte ansehen und prüfen kann. Du kannst mir diese auch gerne per Mail senden, falls Du die Daten hier nicht veröffentlichen willst: ralf (at) kuerbis (dot) org.

Vielen Dank & Beste Grüße,
Ralf

@geschke geschke self-assigned this Jan 31, 2023
@Xtreme89
Copy link
Author

Xtreme89 commented Jan 31, 2023

HI,

MySQL Server 8.0.32-1.el8 läuft. Problem ist ich würde ja gerne MariaDB nehmen, aber das läuft auf Teufel komm raus nicht.

Da kommt nämlich folgender Fehler...

2023-01-31 10:18:47+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.8.6+maria~ubu2204 started.
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47+00:00 [Note] [Entrypoint]: Initializing database files
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] InnoDB: Corrupted page [page id: space=0, page number=0] of datafile './ibdata1' could not be found in the doublewrite buffer.
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] Plugin 'InnoDB' init function returned error.
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] Unknown/unsupported storage engine: InnoDB
grkopv-dashboard-mariadb-1  | 2023-01-31 10:18:47 0 [ERROR] Aborting
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | Installation of system tables failed!  Examine the logs in
grkopv-dashboard-mariadb-1  | /var/lib/mysql/ for more information.
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | The problem could be conflicting information in an external
grkopv-dashboard-mariadb-1  | my.cnf files. You can ignore these by doing:
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  |     shell> /usr/bin/mariadb-install-db --defaults-file=~/.my.cnf
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | You can also try to start the mysqld daemon with:
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  |     shell> /usr/sbin/mariadbd --skip-grant-tables --general-log &
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | and use the command line tool /usr/bin/mariadb
grkopv-dashboard-mariadb-1  | to connect to the mysql database and look at the grant tables:
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  |     shell> /usr/bin/mysql -u root mysql
grkopv-dashboard-mariadb-1  |     mysql> show tables;
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | Try 'mysqld --help' if you have problems with paths.  Using
grkopv-dashboard-mariadb-1  | --general-log gives you a log in /var/lib/mysql/ that may be helpful.
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | The latest information about mysql_install_db is available at
grkopv-dashboard-mariadb-1  | https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
grkopv-dashboard-mariadb-1  | You can find the latest source at https://downloads.mariadb.org and
grkopv-dashboard-mariadb-1  | the maria-discuss email list at https://launchpad.net/~maria-discuss
grkopv-dashboard-mariadb-1  |
grkopv-dashboard-mariadb-1  | Please check all of the above before submitting a bug report
grkopv-dashboard-mariadb-1  | at https://mariadb.org/jira

Solardaten hab ich dir trotzdem mal per eMail geschickt

Gruß Martin

@Xtreme89
Copy link
Author

Xtreme89 commented Jan 31, 2023

So hab das Problem vorerst gelöst.
Habe nun MariaDB 10.6 genommen, damit kriege ich diese Fehlermeldungen nicht mehr. Es werden nun auch die Daten geliefert und Invaps hat keine Fehler mehr.

Wäre natürlich schön, wenn man trotzdem die neuste MariaDB Version nutzen kann oder MySQL

@geschke
Copy link
Owner

geschke commented Jan 31, 2023

Hallo!

Erstmal vielen Dank für all die Mühe des Testens! :-)

Ich habe es hier nun mit MariaDB 10.10.2 (neueste nicht-rc-Variante), aber auch 10.8.6 (die Version aus Deiner Fehlermeldung) getestet - in beiden Fällen ließ sich MariaDB problemlos starten, inkl. innodb-Plugin:

invatest-mariadb-1    | 2023-01-31 13:51:01+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
invatest-mariadb-1    | 2023-01-31 13:51:01+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.10.2+maria~ubu2204 started.
invatest-mariadb-1    | 2023-01-31 13:51:01+00:00 [Note] [Entrypoint]: Initializing database files
invatest-mariadb-1    |
invatest-mariadb-1    |
invatest-mariadb-1    | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
invatest-mariadb-1    | To do so, start the server, then issue the following command:
invatest-mariadb-1    |
invatest-mariadb-1    | '/usr/bin/mysql_secure_installation'
invatest-mariadb-1    |
invatest-mariadb-1    | which will also give you the option of removing the test
invatest-mariadb-1    | databases and anonymous user created by default.  This is
invatest-mariadb-1    | strongly recommended for production servers.
invatest-mariadb-1    |
invatest-mariadb-1    | See the MariaDB Knowledgebase at https://mariadb.com/kb
invatest-mariadb-1    |
invatest-mariadb-1    | Please report any problems at https://mariadb.org/jira
invatest-mariadb-1    |
invatest-mariadb-1    | The latest information about MariaDB is available at https://mariadb.org/.
invatest-mariadb-1    |
invatest-mariadb-1    | Consider joining MariaDB's strong and vibrant community:
invatest-mariadb-1    | https://mariadb.org/get-involved/
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:05+00:00 [Note] [Entrypoint]: Database files initialized
invatest-mariadb-1    | 2023-01-31 13:51:05+00:00 [Note] [Entrypoint]: Starting temporary server
invatest-mariadb-1    | 2023-01-31 13:51:05+00:00 [Note] [Entrypoint]: Waiting for server startup
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] mariadbd (server 10.10.2-MariaDB-1:10.10.2+maria~ubu2204) starting as process 87 ...
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Number of transaction pools: 1
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Completed initialization of buffer pool
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: 128 rollback segments are active.
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] InnoDB: log sequence number 46590; transaction id 14
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] Plugin 'FEEDBACK' is disabled.
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Warning] 'user' entry 'root@ec10437bb40a' ignored in --skip-name-resolve mode.
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Warning] 'proxies_priv' entry '@% root@ec10437bb40a' ignored in --skip-name-resolve mode.
invatest-mariadb-1    | 2023-01-31 13:51:05 0 [Note] mariadbd: ready for connections.
invatest-mariadb-1    | Version: '10.10.2-MariaDB-1:10.10.2+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution
invatest-mariadb-1    | 2023-01-31 13:51:06+00:00 [Note] [Entrypoint]: Temporary server started.
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: Creating database solardb
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: Creating user solardbuser
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: Giving user solardbuser access to schema solardb
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: Securing system users (equivalent to running mysql_secure_installation)
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/solardata.sql
invatest-mariadb-1    |
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:10+00:00 [Note] [Entrypoint]: Stopping temporary server
invatest-mariadb-1    | 2023-01-31 13:51:10 0 [Note] mariadbd (initiated by: unknown): Normal shutdown
invatest-mariadb-1    | 2023-01-31 13:51:10 0 [Note] InnoDB: FTS optimize thread exiting.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Starting shutdown...
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Buffer pool(s) dump completed at 230131 13:51:11
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Shutdown completed; log sequence number 49389; transaction id 19
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] mariadbd: Shutdown complete
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:11+00:00 [Note] [Entrypoint]: Temporary server stopped
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:11+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
invatest-mariadb-1    |
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] mariadbd (server 10.10.2-MariaDB-1:10.10.2+maria~ubu2204) starting as process 1 ...
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Number of transaction pools: 1
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Completed initialization of buffer pool
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: 128 rollback segments are active.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: log sequence number 49389; transaction id 20
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] Plugin 'FEEDBACK' is disabled.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] InnoDB: Buffer pool(s) load completed at 230131 13:51:11
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] Server socket created on IP: '0.0.0.0'.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] Server socket created on IP: '::'.
invatest-mariadb-1    | 2023-01-31 13:51:11 0 [Note] mariadbd: ready for connections.
invatest-mariadb-1    | Version: '10.10.2-MariaDB-1:10.10.2+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution

Analog bei MariaDB 10.8.6:

invatest-mariadb-1    | 2023-01-31 14:17:00 0 [Note] mariadbd: ready for connections.
invatest-mariadb-1    | Version: '10.8.6-MariaDB-1:10.8.6+maria~ubu2204'  socket: '/run/mysqld/mysqld.sock'  port: 0  mariadb.org binary distribution

Mir ist auch ein ziemliches Rätsel, warum MariaDB nicht laufen sollte, aber tatsächlich finden sich bei MariaDB dazu Hinweise, dass es wiederum an der Prozessor-Architektur liegt (siehe MariaDB/mariadb-docker#318 ). Die MariaDB-Leute werden sich sicherlich über einen Bug-Report freuen, wenn der Fehler bei neueren Versionen ebenfalls wieder auftritt. :-)

Die Kompatibilität zu MySQL werde ich mir demnächst noch ansehen.

Beste Grüße,
Ralf

@Xtreme89
Copy link
Author

Sehr komisch

Welche OS läuft bei dir? Sollte zwar unabhängig sein aber der Teufel ist ja ein Eichhörnchen.

Docker Compose als root gestartet oder anders?

@geschke
Copy link
Owner

geschke commented Jan 31, 2023

OS ist Ubuntu 20.04 LTS bzw. 22.04 LTS, je nach VM, aber eben auf einer amd64-Architektur, und nicht auf einem Raspberry Pi.

Ich habe mir nun das MySQL-Problem vorgeknöpft, und die SQL-Requests so angepasst, dass sie jetzt sowohl mit MariaDB, als auch mit MySQL funktionieren (getestet mit dem offiziellen Docker-Image für MySQL in der latest-Fassung bzw. Version 8.0.32). Die Docker-Images sind jedoch wiederum ausschließlich für amd64 gebaut, somit nicht für den Raspberry geeignet (siehe #1, da muss einiges bzgl. des Builds hinzugefügt werden).

Würde mich sehr über Feedback freuen, ob es bei Dir ebenfalls mit MySQL nun läuft.

Zum Hintergrund: Tatsächlich ist MySQL ein wenig strenger, was den json_path anbetrifft, weshalb eine Anpassung der JSON-VALUE()-Abfragen notwendig wurde. Während MariaDB den Doppelpunkt (":") innerhalb der Abfrage als Bestandteil eines JSON-Keys zulässt, führt dies bei MySQL zu einem Fehler. Daher mussten die Namen der Keys mit doppelten Anführungszeichen umschlossen werden. Daraufhin gab es noch ein weiteres Problem angesichts der Einstellung ONLY_FULL_GROUP_BY, die standardmäßig enabled ist. MySQL erlaubte dabei nicht die Abfrage von id und dt_created als nicht-aggregierte Felder in Requests mit der avg()-Funktion und group-by. Da von invaps bzw. Prometheus beide Felder nicht genutzt werden und somit genaugenommen unnötig sind, sind die SQL-Queries ebenfalls angepasst worden.

@Xtreme89
Copy link
Author

MySQL bzw Maria dB läuft auch auf Ubuntu aber 18.04 amd64.
Nur der inafetch läuft im lokalen Netz auf dem pi. Rest auf ubuntu 18.04.

Schau ich mir gerne an und gebe dir Feedback vielen Dank!

@Xtreme89
Copy link
Author

Xtreme89 commented Feb 5, 2023

Bin leider noch nicht dazu gekommen, habe es aber noch auf dem Zettel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants