Coder Social home page Coder Social logo

Comments (5)

smortex avatar smortex commented on June 1, 2024 1

Is it related to your (email ...)?

In order to test your code, I replaced it with #(info %):

(logging/init {:file "/var/log/riemann/riemann.log"})

(let [host "127.0.0.1"]
  (tcp-server {:host host})
  (udp-server {:host host})
  (ws-server  {:host host}))

; Expire old events from the index every 5 seconds.
(periodically-expire 5)

(let [index (index)]
  ; Inbound events will be passed to these streams:
  (streams
    (default :ttl 60
      ; Index all events immediately.
      ;index

      (by [:host :service]
          (where (state "critical")
                 (where (tagged "dummy_alert")
                        (throttle 3 30
                                  #(info %)))))

      ; Log expired events.
      (expired
        (fn [event] (info "expired" event))))))

Then send some events:

r = Riemann::Client.new.tcp
['n1', 'n2', 'n3'].each do |service|
  10.times do |n|
    r << {
           host: "TESTING",
           service: service,
           state: 'critical',
           tags: ["dummy_alert"],
           ttl: 3600,
           description: n,
         }
  end
end

and got the expected outcome in the log file:

INFO [2023-04-06 16:36:58,520] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n1, :state critical, :description 0, :metric nil, :tags [dummy_alert], :time 1.680835018520078E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,522] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n1, :state critical, :description 1, :metric nil, :tags [dummy_alert], :time 1.680835018521604E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,524] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n1, :state critical, :description 2, :metric nil, :tags [dummy_alert], :time 1.680835018523878E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,531] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n2, :state critical, :description 0, :metric nil, :tags [dummy_alert], :time 1.680835018531222E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,532] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n2, :state critical, :description 1, :metric nil, :tags [dummy_alert], :time 1.680835018532433E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,533] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n2, :state critical, :description 2, :metric nil, :tags [dummy_alert], :time 1.680835018533418E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,542] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n3, :state critical, :description 0, :metric nil, :tags [dummy_alert], :time 1.680835018541492E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,543] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n3, :state critical, :description 1, :metric nil, :tags [dummy_alert], :time 1.680835018543208E9, :ttl 3600.0}
INFO [2023-04-06 16:36:58,545] defaultEventExecutorGroup-2-3 - riemann.config - #riemann.codec.Event{:host TESTING, :service n3, :state critical, :description 2, :metric nil, :tags [dummy_alert], :time 1.680835018544439E9, :ttl 3600.0}

from riemann.

Magesh-B avatar Magesh-B commented on June 1, 2024

Hi @smortex, Your observation is very insightful, thank you. Since email is an inbuilt function, I don't think that could have been the issue. Can you be able to reproduce the issue when using email?

from riemann.

smortex avatar smortex commented on June 1, 2024

Hum 🤔 I can't find any email function in the API

I adjusted my test example like this, defining my own email:

--- /usr/local/etc/riemann/riemann.config.orig	2023-04-10 10:45:38.625538000 -1000
+++ /usr/local/etc/riemann/riemann.config	2023-04-10 10:46:30.465567000 -1000
@@ -13,7 +13,9 @@
 ; Expire old events from the index every 5 seconds.
 (periodically-expire 5)
 
-(let [index (index)]
+
+(let [index (index)
+      email (mailer)]
   ; Inbound events will be passed to these streams:
   (streams
     (default :ttl 60
@@ -24,6 +26,7 @@
           (where (state "critical")
                  (where (tagged "dummy_alert")
                         (throttle 3 30
+                                  (email "romain@localhost")
                                   #(info %)))))
 
       ; Log expired events.

I received the 9 expected messages, the 3 first of each host. Maybe you can post your email definition?

from riemann.

Magesh-B avatar Magesh-B commented on June 1, 2024

Apologies for the delayed response, the definition of email function is as follows:
(def email (mailer {:from "[email protected]" :host "email_api_service_provider.com" :user "[email protected]" :pass "password" :port port_number :ssl :yes :body (fn [events] (apply prn-str events)) }))

from riemann.

sanel avatar sanel commented on June 1, 2024

@Magesh-B can you create a simple riemann.config with #(info %), instead of (email) and try to reproduce this?

from riemann.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.