# filters kernel messages
{
  resource."graylog_pipeline_rule" = {

    routeToHomeAssistant = {

      description = "route hass messages to hass stream (TF)";
      source = ''
        rule "route hass message"
        when
          to_string($message.facility) == "hass"
        then
          route_to_stream(id:"''${ graylog_stream.homeassistant.id }", remove_from_default: true);
        end
      '';
    };

  };

  graylog.all_messages.rules = [ "route hass message" ];

  graylog.stream.homeassistant = {
    index_set_id = "\${data.graylog_index_set.default.id}";
    #pipelines = [ "\${graylog_pipeline.processHomeAssistantMessage.id}" ];
    #pipelines = [ "\${graylog_pipeline.processHomeAssistantMessage.id}" ];
  };

  #graylog.pipeline.processHomeAssistantMessage = {
  #  source = ''
  #    stage 0 match all
  #      rule "extract firewall deny";
  #  '';
  #  description = "process messages of the kernel stream(TF)";
  #};

}