dan-s1 commented on code in PR #10935:
URL: https://github.com/apache/nifi/pull/10935#discussion_r2855348617
##########
nifi-extension-bundles/nifi-azure-bundle/nifi-azure-reporting-task/src/main/java/org/apache/nifi/reporting/azure/loganalytics/AbstractAzureLogAnalyticsReportingTask.java:
##########
@@ -57,41 +59,80 @@ public abstract class
AbstractAzureLogAnalyticsReportingTask extends AbstractRep
.ofPattern("EEE, dd MMM yyyy HH:mm:ss O");
static final PropertyDescriptor LOG_ANALYTICS_WORKSPACE_ID = new
PropertyDescriptor.Builder()
- .name("Log Analytics Workspace Id").description("Log Analytics
Workspace Id").required(true)
+ .name("Log Analytics Workspace Id")
+ .description("Log Analytics Workspace Id")
+ .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
-
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build();
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .sensitive(true)
+ .build();
+
static final PropertyDescriptor LOG_ANALYTICS_WORKSPACE_KEY = new
PropertyDescriptor.Builder()
- .name("Log Analytics Workspace Key").description("Azure Log
Analytic Worskspace Key").required(true)
+ .name("Log Analytics Workspace Key")
+ .description("Azure Log Analytics Workspace Key")
+ .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
-
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build();
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .sensitive(true)
+ .build();
+
static final PropertyDescriptor APPLICATION_ID = new
PropertyDescriptor.Builder()
.name("Application ID")
.description("The Application ID to be included in the metrics
sent to Azure Log Analytics WS")
-
.required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT).defaultValue("nifi")
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
+ .required(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
+ .defaultValue("nifi")
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .build();
+
static final PropertyDescriptor INSTANCE_ID = new
PropertyDescriptor.Builder()
.name("Instance ID")
.description("Id of this NiFi instance to be included in the
metrics sent to Azure Log Analytics WS")
-
.required(true).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
-
.defaultValue("${hostname(true)}").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
+ .required(true)
+ .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
+ .defaultValue("${hostname(true)}")
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .build();
+
static final PropertyDescriptor PROCESS_GROUP_IDS = new
PropertyDescriptor.Builder()
.name("Process Group IDs")
- .description(
- "If specified, the reporting task will send metrics the
configured ProcessGroup(s) only. Multiple IDs should be separated by a comma.
If"
- + " none of the group-IDs could be found or no IDs
are defined, the Root Process Group is used and global metrics are sent.")
-
.required(false).expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
+ .description("""
+ If specified, the reporting task will send metrics the
configured ProcessGroup(s) only.
+ Multiple IDs should be separated by a comma. If none of
the group-IDs could be found or
+ no IDs are defined, the Root Process Group is used and
global metrics are sent.""")
+ .required(false)
+ .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.addValidator(StandardValidators.createListValidator(true, true,
StandardValidators.createRegexMatchingValidator(Pattern.compile("[0-9a-z-]+"))))
.build();
- static final PropertyDescriptor JOB_NAME = new
PropertyDescriptor.Builder().name("Job Name")
- .description("The name of the exporting
job").defaultValue("nifi_reporting_job")
+
+ static final PropertyDescriptor JOB_NAME = new PropertyDescriptor.Builder()
+ .name("Job Name")
+ .description("The name of the exporting job")
+ .defaultValue("nifi_reporting_job")
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
- .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
+ .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+ .build();
+
static final PropertyDescriptor LOG_ANALYTICS_URL_ENDPOINT_FORMAT = new
PropertyDescriptor.Builder()
- .name("Log Analytics URL Endpoint Format").description("Log
Analytics URL Endpoint Format").required(false)
+ .name("Log Analytics URL Endpoint Format")
+ .description("Log Analytics URL Endpoint Format")
+ .required(false)
.defaultValue("https://{0}.ods.opinsights.azure.com/api/logs?api-version=2016-04-01")
- .addValidator(StandardValidators.URL_VALIDATOR)
-
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT).build();
+ .addValidator((subject, input, context) -> {
+ if (context.isExpressionLanguageSupported(subject) &&
context.isExpressionLanguagePresent(input)) {
+ return new
ValidationResult.Builder().subject(subject).input(input).explanation("Expression
Language Present").valid(true).build();
+ }
+ try {
+ new URI(MessageFormat.format(input,
"workspace-id")).toURL();
+ return new
ValidationResult.Builder().subject(subject).input(input).valid(true).build();
+ } catch (final Exception e) {
+ return new
ValidationResult.Builder().subject(subject).input(input).valid(false)
+ .explanation("'%s' is not a valid URL format:
%s".formatted(input, e.getMessage())).build();
+ }
Review Comment:
@pvillard31 I made an update as I didn't realize before what you were
testing and what you placed in the valid message.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]