Class ElasticCollector

java.lang.Object
io.kubfly.sdk.collector.elastic.ElasticCollector
All Implemented Interfaces:
Collector

public final class ElasticCollector extends Object implements Collector
The collector of Elasticsearch and OpenSearch: what KubFly records, as documents of the Elastic Common Schema (Documents) in the data streams logs-kubfly-* (events, alerts, health), metrics-kubfly-* (one document per metric and interval) and, by choice, traces-kubfly-* (frames) — sent by the bulk API in Smile (kubfly-sdk-codec). On when the URL of the cluster is set (KUBFLY_COLLECTOR_ELASTIC_URL); its settings are its own (Config), the other collectors do not matter.

At its start the sender asks the cluster what it is (Elasticsearch or OpenSearch), puts the index templates of the data streams (Templates) and, with KUBFLY_COLLECTOR_ELASTIC_KIBANA, imports the data views and the dashboard into Kibana; a cluster that does not answer yet is asked again, at most once a minute, and nothing waits for it.

The threads of the application never send: they put what they got into a bounded queue, and the thread kf-elastic writes the documents and sends them — a bulk when a batch is full or the oldest document has waited KUBFLY_COLLECTOR_ELASTIC_DELAY. The answer of a bulk is read item by item: the documents the cluster could not take now (429, 5xx) are sent again, the refused ones (a mapping, a size) are lost with the reason of the first; the count of the lost documents is a document of its own.

  • Constructor Summary

    Constructors
    Constructor
    Description
    The collector by its configuration (Config), found by ServiceLoader.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    alert(long id, long begin, long end, Metric metric, Severity severity, long warnings, long criticals, long unassessed)
    The state of a metric with thresholds: a document when it changes (the first OK is not a change).
    void
    begin(long id, long time, Frame frame)
    A frame begins: nothing, its document is sent when it ends.
    boolean
    Not a bridge to another logging system.
    boolean
    Whether the collector is on.
    void
    end(long id, long time, long duration, long threadId, String threadName, Frame frame, Throwable exception)
    A frame ends: a document of traces-kubfly-*, when the frames are documents.
    void
    event(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, ArgumentKind kind1, long bits1, Object ref1, ArgumentKind kind2, long bits2, Object ref2, Throwable exception)
    An event: a document of logs-kubfly-*.
    void
    eventN(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, Object[] args, int count, Throwable exception)
    void
    finish(long id, long time, Environment environment)
    The process finishes: what waits is sent before the process goes.
    boolean
    frames(String project, String module, String area, String system, String component)
    The frames of every scope, when they are documents.
    void
    health(long id, long time, long duration, HealthCheck check, Health health)
    A run of a check: a document when its state changes (the first OK is not a change).
    void
    metrics(long id, long begin, long end, Snapshot[] snapshots)
    An interval of metrics: documents of metrics-kubfly-*, of the metrics with observations.
    void
    profile(long id, long begin, long end, Profile profile)
    Not sent: a store of logs is not for the profiles.
    void
    start(long id, long time, Environment environment)
    The process starts: its place, and the problems of the configuration as warnings.
    threshold(String project, String module, String area, String system)
    The lowest level of the events sent.
    void
    track(long id, long time, KubFly kubfly, TrackPoint point)
    A point of a track: a document of logs-kubfly-* at the time of its fix, when the points are documents (KUBFLY_COLLECTOR_ELASTIC_TRACKS); its place is a geo_point.
    void
    traffic(long id, long begin, long end, Edge[] edges)
    Not sent: a store of logs is not for the links of the traffic.
    void
    usage(long id, long time, Usage usage)
    Usage snapshots are not sent: their metrics are.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ElasticCollector

      public ElasticCollector()
      The collector by its configuration (Config), found by ServiceLoader.
  • Method Details

    • enabled

      public boolean enabled()
      Whether the collector is on.
      Specified by:
      enabled in interface Collector
      Returns:
      KUBFLY_COLLECTOR_ELASTIC with a URL
    • bridge

      public boolean bridge()
      Not a bridge to another logging system.
      Specified by:
      bridge in interface Collector
      Returns:
      false
    • frames

      public boolean frames(String project, String module, String area, String system, String component)
      The frames of every scope, when they are documents.
      Specified by:
      frames in interface Collector
      Parameters:
      project - the first level of the scope path
      module - the second path level: a module of the build of the project
      area - the third level
      system - the fourth level
      component - the fifth level
      Returns:
      KUBFLY_COLLECTOR_ELASTIC_FRAMES
    • threshold

      public Level threshold(String project, String module, String area, String system)
      The lowest level of the events sent.
      Specified by:
      threshold in interface Collector
      Parameters:
      project - the first level of the path
      module - the second path level: a module of the build of the project
      area - the third level
      system - the fourth level
      Returns:
      the level, Level.OFF when off
    • start

      public void start(long id, long time, Environment environment)
      The process starts: its place, and the problems of the configuration as warnings.
      Specified by:
      start in interface Collector
      Parameters:
      id - the number
      time - the time
      environment - the environment
    • begin

      public void begin(long id, long time, Frame frame)
      A frame begins: nothing, its document is sent when it ends.
      Specified by:
      begin in interface Collector
      Parameters:
      id - the number of the beginning: that of the frame, frame.id()
      time - the time
      frame - the frame
    • event

      public void event(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, ArgumentKind kind1, long bits1, Object ref1, ArgumentKind kind2, long bits2, Object ref2, Throwable exception)
      An event: a document of logs-kubfly-*.
      Specified by:
      event in interface Collector
      Parameters:
      id - the number
      time - the time
      threadId - the thread (Thread.threadId())
      threadName - the name of the thread (Thread.getName())
      frame - the frame or null
      event - the event
      message - the template
      kind1 - the first kind
      bits1 - the first primitive
      ref1 - the first reference
      kind2 - the second kind
      bits2 - the second primitive
      ref2 - the second reference
      exception - the exception or null
    • eventN

      public void eventN(long id, long time, long threadId, String threadName, Frame frame, Event event, String message, Object[] args, int count, Throwable exception)
      Specified by:
      eventN in interface Collector
      Parameters:
      id - the number
      time - the time
      threadId - the thread (Thread.threadId())
      threadName - the name of the thread (Thread.getName())
      frame - the frame or null
      event - the event
      message - the template
      args - the arguments as the application passed them
      count - the number of the arguments
      exception - the exception or null
    • track

      public void track(long id, long time, KubFly kubfly, TrackPoint point)
      A point of a track: a document of logs-kubfly-* at the time of its fix, when the points are documents (KUBFLY_COLLECTOR_ELASTIC_TRACKS); its place is a geo_point.
      Specified by:
      track in interface Collector
      Parameters:
      id - the number of the point
      time - the time of the call
      kubfly - the KubFly that tracks
      point - the point
    • end

      public void end(long id, long time, long duration, long threadId, String threadName, Frame frame, Throwable exception)
      A frame ends: a document of traces-kubfly-*, when the frames are documents.
      Specified by:
      end in interface Collector
      Parameters:
      id - the number of the end
      time - the time
      duration - the duration, ns
      threadId - the thread (Thread.threadId())
      threadName - the name of the thread (Thread.getName())
      frame - the frame
      exception - the exception or null
    • usage

      public void usage(long id, long time, Usage usage)
      Usage snapshots are not sent: their metrics are.
      Specified by:
      usage in interface Collector
      Parameters:
      id - the number
      time - the time
      usage - the snapshot
    • metrics

      public void metrics(long id, long begin, long end, Snapshot[] snapshots)
      An interval of metrics: documents of metrics-kubfly-*, of the metrics with observations.
      Specified by:
      metrics in interface Collector
      Parameters:
      id - the number of the interval
      begin - the beginning
      end - the end
      snapshots - the snapshots
    • alert

      public void alert(long id, long begin, long end, Metric metric, Severity severity, long warnings, long criticals, long unassessed)
      The state of a metric with thresholds: a document when it changes (the first OK is not a change).
      Specified by:
      alert in interface Collector
      Parameters:
      id - the number of the alert
      begin - the beginning
      end - the end
      metric - the metric
      severity - the state
      warnings - beyond the warning threshold
      criticals - beyond the critical threshold
      unassessed - not assessed
    • traffic

      public void traffic(long id, long begin, long end, Edge[] edges)
      Not sent: a store of logs is not for the links of the traffic.
      Specified by:
      traffic in interface Collector
      Parameters:
      id - the number of the interval of the traffic
      begin - the beginning of the interval
      end - the interval end
      edges - the edges
    • profile

      public void profile(long id, long begin, long end, Profile profile)
      Not sent: a store of logs is not for the profiles.
      Specified by:
      profile in interface Collector
      Parameters:
      id - the number of the profile
      begin - the beginning of the interval
      end - the interval end
      profile - the profile
    • health

      public void health(long id, long time, long duration, HealthCheck check, Health health)
      A run of a check: a document when its state changes (the first OK is not a change).
      Specified by:
      health in interface Collector
      Parameters:
      id - the number of the result
      time - the time
      duration - the duration, ns
      check - the check
      health - the result
    • finish

      public void finish(long id, long time, Environment environment)
      The process finishes: what waits is sent before the process goes.
      Specified by:
      finish in interface Collector
      Parameters:
      id - the number
      time - the time
      environment - the environment