You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/04/07 07:20:01 UTC

[GitHub] [nifi] malthe opened a new pull request, #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

malthe opened a new pull request, #5943:
URL: https://github.com/apache/nifi/pull/5943

   #### Description of PR
   
   This fixes the occasional "403 Forbidden" bug that we have seen, simply because the signature ends up being invalid due to an invalid datetime format used.
   
   Reference: https://stackoverflow.com/a/51636763/647151.
   
   Also related to https://issues.apache.org/jira/browse/NIFI-9866.
   
   ### For all changes:
   - [x] Is there a JIRA ticket associated with this PR? Is it referenced 
        in the commit message?
   
   - [x] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
   
   - [x] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
   
   - [x] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
   
   ### For code changes:
   - [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
   - [ ] Have you written or updated unit tests to verify your changes?
   - [ ] Have you verified that the full build is successful on JDK 8?
   - [ ] Have you verified that the full build is successful on JDK 11?
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
   - [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
   - [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] kevdoran commented on a diff in pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

Posted by GitBox <gi...@apache.org>.
kevdoran commented on code in PR #5943:
URL: https://github.com/apache/nifi/pull/5943#discussion_r856236860


##########
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java:
##########
@@ -136,7 +136,7 @@ protected void sendToLogAnalytics(final HttpPost request, final String workspace
 
         final int bodyLength = rawJson.getBytes(UTF8).length;
         final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
-        final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
+        final String nowRfc1123 = zNow.format(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss O"));

Review Comment:
   In taking a closer look, this is correct, and also I noticed a static formatter is defined (and unused) at the top of the class. Can we use that?
   ```suggestion
           final String nowRfc1123 = zNow.format(RFC_1123_DATE_TIME);
   ```
   
   Also, perhaps it's worth adding a comment for the static formatter explaining why it is necessary to use that instead of `DateTimeFormatter.RFC_1123_DATE_TIME`, to avoid confusion and possible regression for future maintainers. Something like:
   
   ```java
   // DateTimeFormatter.RFC_1123_DATE_TIME does not work in every case, such as when a
   // two-digit day of month is always required, so we are defining our own formatter here.
   private static final DateTimeFormatter RFC_1123_DATE_TIME = DateTimeFormatter
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] kevdoran commented on a diff in pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

Posted by GitBox <gi...@apache.org>.
kevdoran commented on code in PR #5943:
URL: https://github.com/apache/nifi/pull/5943#discussion_r856207666


##########
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java:
##########
@@ -136,7 +136,7 @@ protected void sendToLogAnalytics(final HttpPost request, final String workspace
 
         final int bodyLength = rawJson.getBytes(UTF8).length;
         final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
-        final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
+        final String nowRfc1123 = zNow.format(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss O"));

Review Comment:
   Nevermind, I read the DateFormatter docs too quickly... this seems correct to me. Will do a quick test and should be able to approve this



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] malthe commented on a diff in pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

Posted by GitBox <gi...@apache.org>.
malthe commented on code in PR #5943:
URL: https://github.com/apache/nifi/pull/5943#discussion_r856861774


##########
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java:
##########
@@ -136,7 +136,7 @@ protected void sendToLogAnalytics(final HttpPost request, final String workspace
 
         final int bodyLength = rawJson.getBytes(UTF8).length;
         final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
-        final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
+        final String nowRfc1123 = zNow.format(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss O"));

Review Comment:
   Funny how the bugfix was there all along, just unused! I hadn't even noticed. I have corrected the code now using your suggestion verbatim :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] kevdoran commented on a diff in pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

Posted by GitBox <gi...@apache.org>.
kevdoran commented on code in PR #5943:
URL: https://github.com/apache/nifi/pull/5943#discussion_r856200758


##########
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java:
##########
@@ -136,7 +136,7 @@ protected void sendToLogAnalytics(final HttpPost request, final String workspace
 
         final int bodyLength = rawJson.getBytes(UTF8).length;
         final ZonedDateTime zNow = ZonedDateTime.now(ZoneOffset.UTC);
-        final String nowRfc1123 = zNow.format(DateTimeFormatter.RFC_1123_DATE_TIME);
+        final String nowRfc1123 = zNow.format(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss O"));

Review Comment:
   Based on my reading of RFC-1123 and the [Azure Log Analytics docs](https://docs.microsoft.com/en-us/rest/api/loganalytics/create-request), I think it would be better to use `GMT` in place of `0` in the tz/offset field
   ```suggestion
           final String nowRfc1123 = zNow.format(DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss GMT"));
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] kevdoran closed pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails

Posted by GitBox <gi...@apache.org>.
kevdoran closed pull request #5943: NIFI-9888 Publishing metrics to Log Analytics ocassionally fails
URL: https://github.com/apache/nifi/pull/5943


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org