telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

feat: Add Azure Monitor input plugin

Open ShiranAvidov opened this issue 3 years ago • 23 comments

Required for all PRs:

  • [x] Updated associated README.md.
  • [x] Wrote appropriate unit tests.
  • [x] Pull request title or commits are in conventional commit format

resolves #7930

ShiranAvidov avatar Nov 14 '21 11:11 ShiranAvidov

Hi @srebhan,
I changed the code according your comments.

Happy holidays :)

ShiranAvidov avatar Dec 26 '21 16:12 ShiranAvidov

@ShiranAvidov if you could please rebase on master and resolve the conflicts with go.mod that would help keep this PR moving.

Thanks!

powersj avatar Jan 04 '22 14:01 powersj

I am working on using the azure sdk for resources and collecting metrics. I will update soon.

ShiranAvidov avatar Jan 13 '22 15:01 ShiranAvidov

@ShiranAvidov thanks for looking into the SDK. Please also note that they have zillions of packages, so if you miss some functionality maybe also look at the neighboring packages. :-) Thanks again for your effort!

srebhan avatar Jan 24 '22 09:01 srebhan

Hey @srebhan, hope you are doing well. I finished updating the code + tests.

ShiranAvidov avatar Mar 20 '22 16:03 ShiranAvidov

Hi @ShiranAvidov. I'm glad to see a PR open for a plugin I was looking for. I played around with this a bit and have a few ideas.

I'm concerned over the timeStamp label causing high cardinality. I'd be curious to know @srebhan opinion on this. For now I'm using fielddrop in my config to get rid of it.

And then a feature idea here (not something that needs to be in this PR, it will probably require a bit of work) could be the ability to backfill data. Right now it looks like every interval it grabs the latest data point. A single API call is capable of pulling a days worth of datapoints. Instead of making an API call every minute to get 1 minute metric resolution, it'd be cool if I were able to set the interval to a greater time and it backfill data for that entire interval. This would save a lot of cost on API calls for when I don't necessarily need the data to be as live as possible. I will admit there's some nuances to a feature like this that probably make it easier said than done. Off the top of my head I can think of interval jitter causing there to be overlapping datapoints.

Thanks for making this plugin. It's simple to use, works well, and I have a use case for something just like this.

cthiel42 avatar Apr 26 '22 20:04 cthiel42

@ShiranAvidov Cool helpful plugin. I'm looking forward to see the new functionalty in the near future inside the Telegraf.

ZPascal avatar May 11 '22 13:05 ZPascal

Honestly speaking an integration would require to dramatically reduce the code size by either using existing libraries or move the inner mechanisms to a "high-level" library hiding the complexity. The present PR has 3.8k of code where around 1.2k is actual functionality and the remaining 2.6k is testing of internal functionality. That's about three times the size of most plugins. I really think this should be a library on it's own (or using an existing library if there is any) and a lean telegraf plugin only calls into this externally maintained lib...

srebhan avatar May 12 '22 12:05 srebhan

Hi @srebhan, I've checked the code a bit deeper and I fully agree that is necessary to clean up/ refactor the code. I've quickly check it and I think it's possible to reduce the real code size to less than 1000 lines. Hi @ShiranAvidov, feel free to ping me if you need support to refactor/ restructure the code.

ZPascal avatar May 12 '22 17:05 ZPascal

Any Expected time on when this could be merged?

infa-pavakuma avatar May 16 '22 11:05 infa-pavakuma

@infa-pavakuma as stated earlier, the PR needs a revamp to reduce the amount of code by either using existing libraries or by moving most of the inner workings to a library. When this happened and the PR is updated I will give it another review. Asking when this will be merged won't speed-up things, but supporting @ShiranAvidov and @ZPascal might... ;-)

srebhan avatar May 16 '22 11:05 srebhan

@srebhan @ZPascal thanks for the feedback. @ZPascal can you please elaborate more about your suggestions to reduce the size of the code? Currently I am using Azure library that lets me send requests to the Azure monitor API.

ShiranAvidov avatar May 17 '22 09:05 ShiranAvidov

@ShiranAvidov and @ZPascal please keep this going! Just ping me if you need my input...

srebhan avatar May 17 '22 09:05 srebhan

@ShiranAvidov I checked your code a bit, and it seems that you have some pre-existing (SDK) methods wrapped in your codebase. I recommend reducing the code size also by separating basic lines of code in a separate/unified library. In the end, it is possible to use this common library within the Telegraf codebase. My offer still stands, if you need assistance with this, we can implement it together.

ZPascal avatar May 17 '22 17:05 ZPascal

Hey @srebhan, I reduced the size of the code. The code is in one file - 235 lines!!!

ShiranAvidov avatar Jul 18 '22 10:07 ShiranAvidov

Hey @ShiranAvidov, is there a chance you can address my comments?

srebhan avatar Aug 11 '22 16:08 srebhan

Hey @srebhan, sorry had a lot of other work to do. I think I can move the data into json files, but I will still have to use the List methods (the load/unmarshal will be in the List methods).

ShiranAvidov avatar Aug 14 '22 08:08 ShiranAvidov

Hey @srebhan, finished fixing the code. I moved all test data to json/toml files as you requested :)

ShiranAvidov avatar Aug 17 '22 16:08 ShiranAvidov

@srebhan finished fixing the code.

ShiranAvidov avatar Aug 28 '22 15:08 ShiranAvidov

Hi @srebhan, is there the possibility to merge the PR?

ZPascal avatar Sep 08 '22 19:09 ZPascal

@srebhan done.

ShiranAvidov avatar Sep 20 '22 15:09 ShiranAvidov

@srebhan Are there still open points from your side? Is the PR mergeable?

ZPascal avatar Sep 28 '22 14:09 ZPascal

@srebhan I think this one looks good and is ready. It does not have the sample config structure we use now, were you planning to do that in a follow up?

powersj avatar Oct 12 '22 15:10 powersj

@srebhan Any news from your side?

ZPascal avatar Oct 24 '22 11:10 ZPascal

@powersj Is there the possibility to rebase and merge it? We want to consume the new functionality.

ZPascal avatar Nov 08 '22 18:11 ZPascal

@ZPascal can you please resolve the remaining conflict?

srebhan avatar Nov 15 '22 12:11 srebhan

I just pushed to resolve the go.sum conflict, let's see if tests pass

powersj avatar Nov 15 '22 15:11 powersj

please run go mod tidy and check in changes, you might have to use the same version of Go as the CI

Doesn't look like it, so still need you to push an update after running go mod tidy

powersj avatar Nov 15 '22 15:11 powersj

@srebhan can you re-reivew, I've cleaned up linter issues, ran make tidy, and moved the sample config out

powersj avatar Nov 16 '22 17:11 powersj