appclacks / mirabelle

A stream processing engine for monitoring
Eclipse Public License 1.0
95 stars 5 forks source link

Unable to export events from cabourotte to influxDB #17

Closed alkahan closed 2 years ago

alkahan commented 2 years ago

I am trying to export data from cabourotte events to InfluxDB give me the error:

error {\n :cause class java.lang.Double cannot be cast to class java.lang.String (java.lang.Double and java.lang.String are in module java.base of loader 'bootstrap')\ 

Event from cabourotte:

{
    "host": "myhost",
    "service": "cabourotte-healthcheck",
    "state": "ok",
    "description": "https healthcheck on mywebsite on www.mywebsite.fr:443: success",
    "metric": 1.463464275,
    "tags": [
        "cabourotte"
    ],
    "time": 1639161276.0,
    "ttl": 120.0,
    "context": "website",
    "healthcheck": "https-mywebsite",
    "site": "mywebsite",
    "source": "configuration"
}

IO Config

{:influxdb {:config {:connection-string "http://127.0.0.1:8086"
                     :bucket "mirabelle"
                     :org "mirabelle"
                     :measurement :metric
                     :default-tags {"project" "mirabelle"}
                     :tags [:service]
                     :fields [:environment]}
            :type :influxdb}}

Stream Config

(streams
 (stream
  {:name :cabourotte :default true}
  (not-expired
    (where [:= :service "cabourotte-healthcheck"]
        (push-io! :influxdb)
        (publish! :cabourotte)))))
mcorbin commented 2 years ago

Hello,

Could you please past here the whole stacktrace from Mirabelle logs ? I will also try to reproduce the issue on my side.

alkahan commented 2 years ago

The complete stack trace :

{"@timestamp":"2021-12-10T18:34:35.255Z","@version":"1","message":"{} #error {
 :cause class java.lang.Double cannot be cast to class java.lang.String (java.lang.Double and java.lang.String are in module java.base of loader 'bootstrap')
 :via
 [{:type java.lang.ClassCastException
   :message class java.lang.Double cannot be cast to class java.lang.String (java.lang.Double and java.lang.String are in module java.base of loader 'bootstrap')
   :at [mirabelle.io.influxdb$event__GT_point invokeStatic influxdb.clj 60]}]
 :trace
 [[mirabelle.io.influxdb$event__GT_point invokeStatic influxdb.clj 60]
  [mirabelle.io.influxdb$event__GT_point invoke influxdb.clj 49]
  [mirabelle.io.influxdb.InfluxIO inject_BANG_ influxdb.clj 121]
  [mirabelle.action$push_io_BANG__STAR_$stream__3258 invoke action.clj 649]
  [mirabelle.action$call_rescue invokeStatic action.clj 33]
  [mirabelle.action$call_rescue invoke action.clj 30]
  [mirabelle.action$where_STAR_$stream__3021 invoke action.clj 57]
  [mirabelle.action$call_rescue invokeStatic action.clj 33]
  [mirabelle.action$call_rescue invoke action.clj 30]
  [mirabelle.action$not_expired_STAR_$stream__3163 invoke action.clj 410]
  [mirabelle.action$call_rescue invokeStatic action.clj 33]
  [mirabelle.action$call_rescue invoke action.clj 30]
  [mirabelle.action$sdo_STAR_$stream__3153 invoke action.clj 359]
  [mirabelle.stream$stream_BANG_ invokeStatic stream.clj 120]
  [mirabelle.stream$stream_BANG_ invoke stream.clj 118]
  [mirabelle.stream.StreamHandler push_BANG_ stream.clj 274]
  [mirabelle.transport.tcp$gen_tcp_handler$handler_fn__21113 invoke tcp.clj 48]
  [clojure.core$run_BANG_$fn__8813 invoke core.clj 7717]
  [clojure.lang.ArrayChunk reduce ArrayChunk.java 58]
  [clojure.core.protocols$fn__8176 invokeStatic protocols.clj 136]
  [clojure.core.protocols$fn__8176 invoke protocols.clj 124]
  [clojure.core.protocols$fn__8136$G__8131__8145 invoke protocols.clj 19]
  [clojure.core.protocols$seq_reduce invokeStatic protocols.clj 31]
  [clojure.core.protocols$fn__8168 invokeStatic protocols.clj 75]
  [clojure.core.protocols$fn__8168 invoke protocols.clj 75]
  [clojure.core.protocols$fn__8110$G__8105__8123 invoke protocols.clj 13]
  [clojure.core$reduce invokeStatic core.clj 6830]
  [clojure.core$run_BANG_ invokeStatic core.clj 7712]
  [clojure.core$run_BANG_ invoke core.clj 7712]
  [mirabelle.transport$handle invokeStatic transport.clj 154]
  [mirabelle.transport$handle invoke transport.clj 150]
  [mirabelle.transport.tcp$tcp_handler invokeStatic tcp.clj 102]
  [mirabelle.transport.tcp$tcp_handler invoke tcp.clj 95]
  [mirabelle.transport.tcp$gen_tcp_handler$fn__21119 invoke tcp.clj 56]
  [mirabelle.transport.tcp.proxy$io.netty.channel.ChannelInboundHandlerAdapter$ff19274a channelRead nil -1]
  [io.netty.channel.AbstractChannelHandlerContext invokeChannelRead AbstractChannelHandlerContext.java 379]
  [io.netty.channel.AbstractChannelHandlerContext access$600 AbstractChannelHandlerContext.java 61]
  [io.netty.channel.AbstractChannelHandlerContext$7 run AbstractChannelHandlerContext.java 370]
  [io.netty.util.concurrent.DefaultEventExecutor run DefaultEventExecutor.java 66]
  [io.netty.util.concurrent.SingleThreadEventExecutor$4 run SingleThreadEventExecutor.java 989]
  [io.netty.util.internal.ThreadExecutorMap$2 run ThreadExecutorMap.java
74]
  [io.netty.util.concurrent.FastThreadLocalRunnable run FastThreadLocalRunnable.java 30]
  [java.lang.Thread run Thread.java 833]]}","logger_name":"mirabelle.transport","thread_name":"defaultEventExecutorGroup-2-1","level":"ERROR","lewel_value":40000}
mcorbin commented 2 years ago

Thank you.

The issue is in your configuration file. :measurement contains the key which will be used to get the InfluxDB point measurement value. InfluxDB measurements should be string, but the :metric field is a Double. You can try to replace :metric by :service in the configuration file.

alkahan commented 2 years ago

By replacing :metric by :service

{:influxdb {:config {:connection-string "http://127.0.0.1:8086"
                     :bucket "mirabelle"
                     :org "mirabelle"
                     :measurement :service
                     :default-tags {"project" "mirabelle"}
                     :tags [:service]
                     :fields [:environment]}
            :type :influxdb}}

Mirabelle send a warning when inserting event in InfluxDB:

{
    "@timestamp": "2021-12-12T07:22:55.083Z",
    "  @version": "1",
    "message": "The point: com.influxdb.client.write.Point@fff4a26doesn't contains any fields, skipping",
    "logger_name": "com.influxdb.client.internal.AbstractWriteClient$BatchWriteDataPoint",
    "thread_name": "defaultEventExecutorGroup-2-1",
    "level": "WARN",
    "level_value": 30000
}
mcorbin commented 2 years ago

You have this warning before in InfluxDB points should have at least one field. You configured fields to [:environment] but the event does not have this key set.

alkahan commented 2 years ago

Hi, Thanks for your response.

I have found the problem. I was trying to push data into InfluxDB v 1.7. Since the beginning, I misunderstood the config options because I was still using an old version of InfluxDB. After installing v2.1 and read the doc, it is OK.

For reference, my IO config.

{:influxdb {:config {:connection-string "http://127.0.0.1:8086"
                     :bucket "mirabelle"
                     :org "my_org"
                     :measurement :service
                     :token #secret "MY_TOKEN"
                     :tags [:service :site]
                     :fields [:metric :state]
}
            :type :influxdb}