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

SC-20509 #4

Open
wants to merge 52 commits into
base: add-sematext-exporter
Choose a base branch
from
Open

SC-20509 #4

wants to merge 52 commits into from

Conversation

AkhigbeEromo
Copy link
Collaborator

Adding logs support following STA pattern

Filtered some things we do not need from the Elastisearch exporter after doing some research
…s not very clean

once things begin to work i will clean it up code.

Also its hard to really differentiate work done into individual commits
But what is going here is i am trying to follow STA pattern of shipping logs to SC
Some of this code was copy and pasted from STA
Had to setup factory settings for the exporter
…some logging statements

Will clean code up once i am done
@AkhigbeEromo AkhigbeEromo marked this pull request as ready for review December 2, 2024 16:10
exporter/sematextexporter/config.go Outdated Show resolved Hide resolved
exporter/sematextexporter/writer.go Outdated Show resolved Hide resolved
for i := 0; i < v.Len(); i++ {
doc := v.Index(i).Interface()
if docMap, ok := doc.(map[string]any); ok {
docMap["os.host"] = getHostname()
Copy link
Member

@akshatagarwl akshatagarwl Dec 17, 2024

Choose a reason for hiding this comment

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

Instead of calling the getHostname func everytime lets save this in the client struct itself as a field similar to what the flinkClient does

logaf: high

// LogMaxSize is the maximum size in megabytes of the log file before it gets rotated
LogMaxSize int `mapstructure:"logs_max_size"`
// WriteEvents determines if events are logged
WriteEvents atomic.Bool `mapstructure:"write_events"`
Copy link
Member

Choose a reason for hiding this comment

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

Question: Why is WriteEvents an atomic.Bool? Is it something that can be updated in multiple threads concurrently?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So this was what was defined in the agent so I literally copied and pasted

Copy link
Member

Choose a reason for hiding this comment

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

Read up on Atomic Counters in Go. It'll help you make a decision if this is really required or not

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just read up on it and yes I believe its required

exporter/sematextexporter/config.go Outdated Show resolved Hide resolved
func (c *client) Bulk(body any, config *Config) error {
if grp, ok := c.clients[config.LogsEndpoint]; ok {
bulkRequest := grp.client.Bulk()
if reflect.TypeOf(body).Kind() == reflect.Slice {
Copy link
Member

Choose a reason for hiding this comment

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

Is using reflect really necessary here?

Copy link
Collaborator Author

@AkhigbeEromo AkhigbeEromo Dec 18, 2024

Choose a reason for hiding this comment

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

yes
But what would you suggest
I tried making changes and it broke my code

"io"
"testing"

"github.com/olivere/elastic"
Copy link
Member

Choose a reason for hiding this comment

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

This library is deprecated now

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The "github.com/olivere/elastic" library?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

exporter/sematextexporter/exporter.go Show resolved Hide resolved
@AkhigbeEromo AkhigbeEromo changed the title Add logs support to Sematext Exporter SC-20509 Add logs support to Sematext Exporter Dec 17, 2024
@AkhigbeEromo AkhigbeEromo changed the title SC-20509 Add logs support to Sematext Exporter SC-20509 Dec 18, 2024
"time"

json "github.com/json-iterator/go"
"github.com/olivere/elastic/v7"
Copy link
Member

Choose a reason for hiding this comment

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

Still using a deprecated lib. Replace with https://github.com/elastic/go-elasticsearch

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done


json "github.com/json-iterator/go"
"github.com/olivere/elastic/v7"
"github.com/sirupsen/logrus"
Copy link
Member

Choose a reason for hiding this comment

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

"github.com/sirupsen/logrus" is in maintenance mode. Lets use something that is being used by other exporters as well like "go.uber.org/zap". See them for the appropriate usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

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.

4 participants