Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logscale: add logscale() destination #4472

Merged
merged 2 commits into from May 18, 2023
Merged

Conversation

alltilla
Copy link
Collaborator

@alltilla alltilla commented May 12, 2023

The logscale() destination feeds LogScale via the Ingest API.

Minimal config:

destination d_logscale {
  logscale(
    token("my-token")
  );
};

Additional options include:

  • url()
  • rawstring()
  • timestamp()
  • timezone()
  • attributes()
  • extra-headers()
  • content-type()

Signed-off-by: Attila Szakacs attila.szakacs@axoflow.com

alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 12, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 12, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 15, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
@alltilla alltilla changed the title logscale: add logscale-hec() and logscale-hec-raw() destinations logscale: add logscale() destination May 15, 2023
@alltilla alltilla marked this pull request as ready for review May 15, 2023 06:50
@alltilla
Copy link
Collaborator Author

Tested with a real instance

Input

<134>1 2011-02-01T15:25:25+01:00 zts-win001 syslog-ng_Agent 3268 - [meta sequenceId="5" sysUpTime="6"][origin ip="zts-win001" software="syslog-ng Agent"][win@18372.4 EVENT_ID="17" EVENT_NAME="Application" EVENT_REC_NUM="2515" EVENT_SID="S-1-5-21-1044605109-3424919905-550079122-1000" EVENT_SID_TYPE="User" EVENT_SOURCE="syslog-ng Agent" EVENT_TYPE="Information" EVENT_USERNAME="ZTS-WIN001\\balabit"] ZTS-WIN001\balabit: Application syslog-ng Agent: [Information] Service Removed (EventID 17)

LogScale

Screenshot from 2023-05-15 08-52-13
Screenshot from 2023-05-15 08-51-55
Screenshot from 2023-05-15 08-52-02

alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 15, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Copy link
Collaborator

@MrAnno MrAnno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise.


# https://library.humio.com/falcon-logscale/api-ingest.html#api-ingest-structured-data
block destination logscale(
url()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add a default here? (cloud.humio.com)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, added.

headers(
"Authorization: Bearer `token`"
"Content-Type: `content_type`"
"Connection: keep-alive"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep-alive is managed by curl (and it is on by default in HTTP/1.1), so I don't think we need this here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed.

alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 17, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
alltilla added a commit to alltilla/syslog-ng that referenced this pull request May 17, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
timezone("")
attributes("--scope rfc5424 --exclude MESSAGE --exclude DATE --leave-initial-dot")

batch_lines(5000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets change these to be a bit safer
batch_lines(1000) #1000 events per post
batch_bytes(1024kB)
batch_timeout(1)
workers(20)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I have changed batch_lines(), batch_bytes() and batch_timeout().

Is there any particular reason for setting workers(20)? In the source code there is a hard limit on the maximum number of workers, and we have multiple http() SCLs and their workers add up. We are trying to balance a bit, so even if a user configures multiple SCL based drivers, they won't hit the hard limit. Because of this I would keep it 8, if you don't mind.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the response time from the http server is 500ms (round trip) we would get about 2 posts per second per thread limiting the throughput to around 20Mbs or 20k eps if we had 10 workers I was going for double that as a modest size firewall source alone can run around that level. http posts are mostly network wait state so a higher number of works is really needed to keep throughput up

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are good points. I think that we should probably separate the concept of a worker and a batch within our HTTP destination. We might be building batches, some of which are being transferred to the server, while the others are still waiting for more data. This way threads would only be occupied while the HTTP transaction happens, thus the number of threads may be a lot lower than the number of batches being built.

If the total number of threads exceeds the compile time constant of 256, we will get this message:

  msg_warning_once("Unable to allocate a unique thread ID. This can only "
                   "happen if the number of syslog-ng worker threads exceeds the "
                   "compile time constant MAIN_LOOP_MAX_WORKER_THREADS. "
                   "This is not a fatal problem but can be a cause for "
                   "decreased performance. Increase this number and recompile "
                   "or contact the syslog-ng authors",
                   evt_tag_int("max-worker-threads-hard-limit", MAIN_LOOP_MAX_WORKER_THREADS));

This only causes decreased performance in the source related threads case, so we might just get rid off this problem by not allocating a thread id for HTTP worker threads, which will never use the thread id at the moment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged it with workers(8), as I would like to generate a container image from master and this PR already had an approve, but opened a PR to raise the workers to 20: #4488

Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
@alltilla alltilla merged commit dce6270 into syslog-ng:master May 18, 2023
16 checks passed
@ryanfaircloth
Copy link
Contributor

ryanfaircloth commented May 18, 2023 via email

HofiOne pushed a commit to HofiOne/syslog-ng that referenced this pull request May 24, 2023
Signed-off-by: Attila Szakacs <attila.szakacs@axoflow.com>
Signed-off-by: Hofi <hofione@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants