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

Question: index mapping creation #43

Open
Eomm opened this issue Jan 16, 2020 · 5 comments
Open

Question: index mapping creation #43

Eomm opened this issue Jan 16, 2020 · 5 comments

Comments

@Eomm
Copy link
Contributor

Eomm commented Jan 16, 2020

I'm sending to elasticsearch an http-request trace with the body. The index created by default will index all the body's fields and my server can't afford all that processing.. moreover, I'm not interested in index all the body fields, they should be just stored (I use other fields for search).

Since I'm using the index: 'pino%{DATE}' pattern, the index is created at runtime by this line if I'm not wrong:

client.index(obj, function (err, data) {

So, I'm not sure if I should configure the mapping of the desired index in this module with an additional feature, or there are other tricks in the elasticseach side.
Could you give me some suggestion?
Thanks

@mcollina
Copy link
Member

mcollina commented Jan 16, 2020 via email

@Eomm
Copy link
Contributor Author

Eomm commented Jan 21, 2020

If you customize that mapping in ES, is that retained on restart of pino-elasticsearch?

Yes, if I create manually an index and then send the logs there, the index ignore the Request key:

{
  "mappings": {
    "log": {
      "properties": {
        "App": {
          "type": "text"
        },
        "Headers": {
          "type": "nested",
          "enabled": false
        },
        "Request": {
          "type": "nested",
          "enabled": false
        }
      }
    }
  }
}

@mcollina
Copy link
Member

Would a flag to avoid adding the mapping be enough then?

@Eomm
Copy link
Contributor Author

Eomm commented Jan 22, 2020

I had the chance to understand better the case:

  • the code I linked send the logs to elastic, it doesn't create the index
  • elastic, cause doesn't have the index of the day, create a new index with the default settings and it will index all the things

The logic I would apply in this module would be:
if the user specified a custom mapping

  • at startup create the index and ignore the error index already create
  • if the user define the %{DATE} index's name, schedule a timeout to create the next index (or "when the generated index name has changed, create it then continue logging")

Am I the only one that would like to apply a different mapping than the default? 🤔 😅

@mcollina
Copy link
Member

mcollina commented Jan 22, 2020 via email

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

No branches or pull requests

2 participants