Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Praktische Anwendungen (Showcase)
    4. Grafana und Prometheus in iobroker ein-bzw.anbinden

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Grafana und Prometheus in iobroker ein-bzw.anbinden

    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bunni last edited by

      Hallo

      ich habe ein riesiges Problem mit der eigentlichen MySql b Bearbeitung, ich komme damit einfach nicht klar mit dem einsetzten der Ordner usw.

      Wenn ich das Script eingebe bekomme ich folgende Fehlermeldungen:

      <code>MariaDB [(none)]> var anz = 0;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var anz = 0' at line 1
      MariaDB [(none)]> var total = 0;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var total = 0' at line 1
      MariaDB [(none)]> var data = "";
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var data = ""' at line 1
      MariaDB [(none)]> var states = $('*').each(function(id, i) {
          -> 
          -> 
          ->     if (getObject(id)) {
          ->         anz = anz + 1;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var states = $('*').each(function(id, i) {
      
          if (getObject(id)) {
              an' at line 1
      MariaDB [(none)]>         try {
          ->             var devname = getObject(id).common.name;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'try {
                  var devname = getObject(id).common.name' at line 1
      MariaDB [(none)]>             var logenabled = getObject(id).common.custom["sql.0"].enabled;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var logenabled = getObject(id).common.custom["sql.0"].enabled' at line 1
      MariaDB [(none)]>             //count total states with sql logging enabled
          ->             total = total + 1;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '//count total states with sql logging enabled
                  total = total + 1' at line 1
      MariaDB [(none)]>             //onlz write states to file with sql logging enabled
          ->             if (logenabled === true) {
          ->                 log('extract : ' + devname);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '//onlz write states to file with sql logging enabled
                  if (logenabled ' at line 1
      MariaDB [(none)]>                 var channel = getObject(id).common.name.split(":");
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var channel = getObject(id).common.name.split(":")' at line 1
      MariaDB [(none)]>                 var dp = getObject(id, "rooms");
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var dp = getObject(id, "rooms")' at line 1
      MariaDB [(none)]>                 var raum = dp.enumNames;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var raum = dp.enumNames' at line 1
      MariaDB [(none)]>                 if (raum.length > 0) {
          ->                     //    log(anz+"->"+id+":::::"+devname+"----"+channel[0]+">"+raum+"<");
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '{
                          //    log(anz+"->"+id+":::::"+devname+"----"+channel[0]+">' at line 1
      MariaDB [(none)]>                 } else {
          ->                     //    log(anz+"->"+id+":::::"+devname+"----"+channel[0]+">"+"----------"+"<");
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '} else {
                          //    log(anz+"->"+id+":::::"+devname+"----"+channe' at line 1
      MariaDB [(none)]>                     raum = "-";
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'raum = "-"' at line 1
      MariaDB [(none)]>                 }
          ->                 data = data + '"' + id + '","' + channel[0] + '","' + devname + '","' + raum + '"' + String.fromCharCode(10);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '}
                      data = data + '"' + id + '","' + channel[0] + '","' + devname ' at line 1
      MariaDB [(none)]> 
      MariaDB [(none)]>             }
          -> 
          -> 
          ->         } catch (err) {}
          ->     }
          -> });
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '}
      
              } catch (err) {}
          }
      })' at line 1
      MariaDB [(none)]> 
      MariaDB [(none)]> //log(data);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '//log(data)' at line 1
      MariaDB [(none)]> var fs = require('fs');
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'var fs = require('fs')' at line 1
      MariaDB [(none)]> fs.writeFile('/home/shares/allusers/namen.csv', data, 'binary', function(error) {
          ->     console.log(' object scanned : ' + anz);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'fs.writeFile('/home/shares/allusers/namen.csv', data, 'binary', function(error) ' at line 1
      MariaDB [(none)]>     console.log(' SQL enabled objects written to file : ' + total);
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'console.log(' SQL enabled objects written to file : ' + total)' at line 1
      MariaDB [(none)]> });/code]</code>
      
      1 Reply Last reply Reply Quote 0
      • L
        Lbpuma3 last edited by

        Hallo,
        Ich habe diese Fehler Meldung (siehe anhang)
        Habe Grafana auf Windows istalliert kann das der Fehler sein?
        Oder muss ich die SQL datenbank erweitern mit (names .....)
        Möchte nur das die Daten die vom Iobroker in die SQL geschrieben werden in Grafana angezeigt werden.
        LG Thomas
        fehler.jpg

        Segway 1 Reply Last reply Reply Quote 0
        • Segway
          Segway @Lbpuma3 last edited by

          @Lbpuma3

          Bei SQL ist es etwas tricky, bin ich selber drüber gestolpert. Warum ? Weil die Datenpunkte nicht autoamtisch angezeigt werden.
          Deshalb suche ich mir in der Datenbank die entsprechende ID raus und die musst du in die vorletzte Zeile eintragen --> n.id = 1422 (ist für eine Temperaturmessung)

          SELECT
            floor(n.ts/1000) as time_sec,
            n.val as value,
            "Temperatur" as metric
          FROM ts_number n
          WHERE $__unixEpochFrom()*1000<n.ts and $__unixEpochTo()*1000>n.ts and n.id = 1422
          ORDER BY n.ts ASC
          
          L 1 Reply Last reply Reply Quote 0
          • L
            Lbpuma3 @Segway last edited by

            @Segway said in Grafana und Prometheus in iobroker ein-bzw.anbinden:

            WHERE $__unixEpochFrom()*1000<n.ts and $__unixEpochTo()*1000>n.ts and n.id = 1422

            Danke du hast mir sehr geholfen.
            Großkleinschreibung bei "__unixEpochTo" war mein Fehler.
            LG

            1 Reply Last reply Reply Quote 0
            • sissiwup
              sissiwup last edited by

              Hallo, um die Auswahl der Datenpunkte einfacher zu gestalten habe ich Variablen eingebaut:

              Anmerkung 2019-03-02 110018.jpg

              Anmerkung 2019-03-02 110055.jpg

              Anmerkung 2019-03-02 110131.jpg

              Device

              SELECT DISTINCT concat(sname," ",mid(name,10,10)," ",raum) FROM `datapoints` where not isnull(sname) and instr(lname,"-") = 3 and instr(lname,":")=6  and length(raum)>1
              

              Geräte:

              SELECT concat(right(concat("0000",id),4)," ",lname,"(",raum,") ",case type when 0 then "Nu" when 1 then "St" when 2 then "Bo" else "?" end) FROM `datapoints` where not isnull(lname) and instr(lname,"-") = 3 and instr(lname,":")=6 and (instr(lname,"BAT")>0 or instr(lname,"MOTION")>0 or instr(lname,"BRIGHT")>0 or instr(lname,"TEMP")>0 or instr(lname,"STATE")>0 or instr(lname,"VALVE")>0 or instr(lname,"HUMI")>0 or instr(lname,"POWER")>0) order by lname
              

              Datapoints

              SELECT concat(right(concat("0000",id),4)," ",lname,"(",raum,") ",case type when 0 then "Nu" when 1 then "St" when 2 then "Bo" else "?" end) FROM `datapoints` where not isnull(lname)  order by lname
              

              Anmerkung 2019-03-02 110239.jpg

              Anmerkung 2019-03-02 110402.jpg

              Anmerkung 2019-03-02 110459.jpg

              Man kann die Variablen auch in Querys verwenden:

              Anmerkung 2019-03-02 111413.jpg

              Anmerkung 2019-03-02 111519.jpg

              Anmerkung 2019-03-02 111147.jpg

              Anmerkung 2019-03-02 111213.jpg

              Segway 2 Replies Last reply Reply Quote 1
              • Segway
                Segway @sissiwup last edited by

                @sissiwup

                Das gibts doch nicht, GENAU DAS HABE ICH GESUCHT !!!!!
                Genial --> 5 STERNE !!!!!!

                1 Reply Last reply Reply Quote 0
                • Segway
                  Segway @sissiwup last edited by

                  @sissiwup sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                  SELECT DISTINCT concat(sname," ",mid(name,10,10)," ",raum) FROM datapoints where not isnull(sname) and instr(lname,"-") = 3 and instr(lname,":")=6 and length(raum)>1

                  Bei mir kommt leider ein Fehler - ne Idee ?
                  c3a8f600-86ca-495f-ae83-eab42c2e0fff-image.png

                  sissiwup 1 Reply Last reply Reply Quote 0
                  • sissiwup
                    sissiwup @Segway last edited by

                    @Segway sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                    @sissiwup sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                    SELECT DISTINCT concat(sname," ",mid(name,10,10)," ",raum) FROM datapoints where not isnull(sname) and instr(lname,"-") = 3 and instr(lname,":")=6 and length(raum)>1

                    Bei mir kommt leider ein Fehler - ne Idee ?
                    c3a8f600-86ca-495f-ae83-eab42c2e0fff-image.png

                    Hi, ggf. musst du bei dir die Abfragten anpassen. Meine Abfragen gehen auf die erweiterten Tabellen (siehe erste Beiträge)

                    1 Reply Last reply Reply Quote 0
                    • Segway
                      Segway @sissiwup last edited by

                      @sissiwup sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                      Jetzt füllen wir die Datenpunkte mit sprechenden Namen:
                      ​````
                      UPDATE datapoints SET lname=(select lname from namen where namen.name=datapoints.name limit 1)
                      UPDATE datapoints SET sname=(select sname from namen where namen.name=datapoints.name limit 1)
                      UPDATE datapoints SET raum=(select raum from namen where namen.name=datapoints.name limit 1)

                      Mal eine Frage:
                      In welcher der angelegten Tabellen muss ich sein um diese Befehle "abzufeuern" ???
                      Einmal ist mir die DB schon abgeschmiert 😞

                      sissiwup 1 Reply Last reply Reply Quote 0
                      • sissiwup
                        sissiwup @Segway last edited by

                        @Segway sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                        @sissiwup sagte in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                        Jetzt füllen wir die Datenpunkte mit sprechenden Namen:
                        ​````
                        UPDATE datapoints SET lname=(select lname from namen where namen.name=datapoints.name limit 1)
                        UPDATE datapoints SET sname=(select sname from namen where namen.name=datapoints.name limit 1)
                        UPDATE datapoints SET raum=(select raum from namen where namen.name=datapoints.name limit 1)

                        Mal eine Frage:
                        In welcher der angelegten Tabellen muss ich sein um diese Befehle "abzufeuern" ???
                        Einmal ist mir die DB schon abgeschmiert 😞

                        Hi,
                        du musst das nur machen, wenn du meine Variablen 1:1 übernehmen willst.
                        Die Tabelle namen im Space iobroker sollte gefüllt sein.
                        Und du updates die Tabelle datapoints. Und es sind 3 einzelne Befehle, sonst per ";" trennen!

                        Segway 1 Reply Last reply Reply Quote 0
                        • Segway
                          Segway @sissiwup last edited by

                          @sissiwup

                          Jo das hatte ich nicht gemacht und jetzt nachgeholt.
                          Kannst du mir einmal erklären, wie nun diese drei Variablen anzuwenden sind wenn ich nun einen Graph erstellen möchte ? SO ganz verstehe ich das noch cniht:

                          ddce3af0-3e2b-4235-be31-0b0e8be09a4d-image.png

                          1 Reply Last reply Reply Quote 0
                          • crunchip
                            crunchip Forum Testing Most Active last edited by

                            https://www.heise.de/newsticker/meldung/Grafana-6-2-legt-mehr-Wert-auf-Sicherheit-4432467.html

                            1 Reply Last reply Reply Quote 0
                            • C
                              ChrisXY last edited by

                              hm ist es nicht einfacher den influxDB Adapter zu nutzen ? Die InfluxDB kommt direkt mit Grafana klar das man da ganz einfach nach Werten und Geräten suchen kann.

                              1 Reply Last reply Reply Quote 0
                              • Knallochse
                                Knallochse last edited by Knallochse

                                Für alle die Probleme mit der Einbindung ins VIS haben

                                https://forum.iobroker.net/topic/23503/welche-proxmox-vms-habt-ihr/101

                                Bei Grafana selber gibt es eine Setting "allow_embedding" in der grafana.ini, welche auf true gestellt werden muss.
                                

                                Danke an @Sempre

                                Diese Einstellung muss ab Grafana Version 6.2 vorgenommen werden, um Dashboards im iFrame darzustellen.

                                arteck 1 Reply Last reply Reply Quote 0
                                • arteck
                                  arteck Developer Most Active @Knallochse last edited by arteck

                                  @Knallochse du solltest mal vielleicht schreiben was die Einstellung bewirkt

                                  allow_embedding
                                  
                                  When false, the HTTP header X-Frame-Options: deny will be set in Grafana HTTP responses which will instruct browsers to not allow rendering Grafana in a <frame>, <iframe>, <embed> or <object>. The main goal is to mitigate the risk of Clickjacking. Default is false.
                                  
                                  Knallochse 1 Reply Last reply Reply Quote 0
                                  • Knallochse
                                    Knallochse @arteck last edited by

                                    Auf Aufforderung von @arteck
                                    Diese Einstellung bewirkt:

                                    allow_embedding
                                    
                                    When false, the HTTP header X-Frame-Options: deny will be set in Grafana HTTP responses which will instruct browsers to not allow rendering Grafana in a <frame>, <iframe>, <embed> or <object>. The main goal is to mitigate the risk of Clickjacking. Default is false.
                                    

                                    😀

                                    1 Reply Last reply Reply Quote 0
                                    • coyote
                                      coyote Most Active last edited by

                                      Habe heute auch Grafana in einem Proxmox Debian 10 Container installiert. Alles ok soweit, läuft mit dem neuen simpleAPI Adapter.
                                      Jetzt meine Frage, bekomme es nicht in Vis eingebettet, obwohl ich "allow_embedding" auf true stehen habe und den Grafana Server neu gestartet habe. Jemand ne Idee woran es liegen kann?
                                      Im iframe steht "Server hat die Verbindung abgelehnt" aber warum?

                                      arteck 1 Reply Last reply Reply Quote 0
                                      • AxelF1977
                                        AxelF1977 @sissiwup last edited by

                                        @sissiwup said in Grafana und Prometheus in iobroker ein-bzw.anbinden:

                                        Zuerst exportieren wir alle Datenpunkte aus iobroker:

                                        im Skriptadapter erzeuge ein Skript:

                                        (Hier nutzt besser die optimierte Version von Dutchman - ein paar Posts weiter unten)

                                        var anz=0;
                                        var data="";
                                        var states = $('*').each(function(id,i) {
                                        
                                            if (getObject(id)) {
                                                anz=anz+1;
                                                var devname=getObject(id).common.name;
                                                var channel=getObject(id).common.name.split(":");
                                                var dp = getObject(id,"rooms");
                                                var raum=dp.enumNames;
                                                if (raum.length>0) {
                                                //    log(anz+"->"+id+":::::"+devname+"----"+channel[0]+">"+raum+"<");
                                                } else {
                                                //    log(anz+"->"+id+":::::"+devname+"----"+channel[0]+">"+"----------"+"<");
                                                    raum="-"
                                                }
                                                data = data + '"'+id+'","'+channel[0]+'","'+devname+'","'+raum+'"'+String.fromCharCode(10);
                                        
                                            }
                                        });
                                          //log(data);
                                          var fs = require('fs');
                                          fs.writeFile('/home/shares/allusers/namen.csv', data,'binary', function (error) {
                                            console.log(' file written-'+anz);
                                        });
                                        

                                        Der Pfad "/home/shares/allusers/namen.csv" muss natürlich angepasst werden.

                                        Im MySQL erzeugen wir eine neue Tabelle:

                                        Hallo zusammen,

                                        @sissiwup , sind diese Schritte auch notwendig, wenn es schon eine prall gefüllt MYSQl Datenbank gibt, mit Werten der letzten 2 Jahre?
                                        Oder kann man hier ab einem anderen Punkt der Anleitung beginnen?

                                        Danke

                                        1 Reply Last reply Reply Quote 0
                                        • arteck
                                          arteck Developer Most Active @coyote last edited by arteck

                                          @coyote hast du den anonymous Zugang frei geschaltet.. und kein https verwenden

                                          coyote 1 Reply Last reply Reply Quote 0
                                          • coyote
                                            coyote Most Active @arteck last edited by

                                            @arteck ist ja schon ne Weile her, aber ja der anonymous Zugang war das Problem. Tut mittlerweile alles 👍

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            Support us

                                            ioBroker
                                            Community Adapters
                                            Donate

                                            814
                                            Online

                                            31.9k
                                            Users

                                            80.1k
                                            Topics

                                            1.3m
                                            Posts

                                            32
                                            167
                                            48268
                                            Loading More Posts
                                            • Oldest to Newest
                                            • Newest to Oldest
                                            • Most Votes
                                            Reply
                                            • Reply as topic
                                            Log in to reply
                                            Community
                                            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                                            The ioBroker Community 2014-2023
                                            logo