What templating parameters does Flink Stateful Functions URL Path Template support? - apache-flink

When deploying Flink Stateful Functions, one needs to specify what the endpoints for the functions are, i.e. what URL does Flink need to hit in order to trigger the execution of a remote function.
The docs state:
The URL template name may contain template parameters that are filled
in based on the function’s specific type. For example, a message sent
to message type com.example/greeter will be sent to
http://bar.foo.com/greeter.
endpoints:
- endpoint:
meta:
kind: http
spec:
functions: com.example/*
urlPathTemplate: https://bar.foo.com/{function.name}
What other templating values does the urlPathTemplate support and where are these values taken from?

The only template value supported at the moment is the function name. i.e. the last value after the last forward slash /. You can place it wherever you would like in the template as long as it would resolve to a legal url at the end.
For example, this is also a valid template:
http://{function.name}.prod.svc.example.com
Then, a message address to com.example/greeter (in your example, with my new template) would resolve to:
http://greeter.prod.svc.example.com
If you are missing any other template parameters, feel free to connect with the Flink community over the user mailing list/JIRA. I'm sure they would be happy to learn about new uses cases ;-)

Related

Passing parameters to SSPRS Report through the URL doesn't work

I'm trying to access a SSPRS report that has the option to select the year and the month by adding the parameters in the URL as &param=value but I always get the default.
This are the parameters and I know I'm sending the correct values in the URL.
This is the report panel where I can select the Year and Month, I'm trying to get the specific report that I need by passing those parameters in the URL.
What could I be doing wrong?
Thank you everyone.
There are a couple of ways these go wrong, I'm guessing your problem is URL encoding of your date parameter, but I'll give you other stuff too. Here is a working URL with 3 parameters: a date, a string, and an integer.
https://db01.MyCompany.com/ReportServer_Prod?/Reports/R440_OutstandingRecp&paramDateEnd=12%2f31%2f2015&paramPropLiab=Property&paramRepPeriod=1
The key parts of this URL:
"https://db01.MyCompany.com/ReportServer_Prod?/" - db01.MyCompany.com is our database VM, and I'm using the "Prod" (production) instance of SQL on it.
NOTE: Check your Reporting Services Configuration application and look at the "Web Service URL" to get what "ReportServer_Prod" is on your installation.
"?/Reports/" is the path to the virtual directory, note that this is different from the path a browser would normally use. Normally my path would be "ReportServer_Prod/Pages/Report.aspx?ItemPath=%2fReports%2fR440_OutstandingRecp" if I was just viewing this from the Reporting Services interface.
Parameters are separated by "&" and it's "ParamName" "=" "ParamValue" so "&paramPropLiab=Property&paramRepPeriod=1" are the string and integer parameters respectively.
Lastly, parameter values are URL encoded if necessary. Mostly it doesn't show up, but for dates and some strings, it becomes necessary. We can't send something like "12/31/2015" because it looks like part of the path, we need a URL encoded string like "12%2f31%2f2015"
Hopefully one (or more) of these were what you needed, reply in the comments if it's still not working or if you need more explanation of why the parts are what they are.
EDIT: One more thing, if a parameter has a "Display" and a "Value" (i.e. in a drop down list) you must pass the value, not the display.
EDIT: I can't make the comment stop hiding my URL, so I'll put it here
WHAT WAS TRIED
https://slo2000/Reports_TECOVA?/Reports/TEXO%20CVA%20Reports%2fTEXO_London_B_CVA_Report&ReportMonth=January&ReportYear=2020
https://slo2000/Reports_TECOVA?/Reports/TEXO%20CVA%20Reports/TEXO_London_B_CVA_Report&ReportMonth=January&ReportYear=2020
https://slo2000/ReportServer_TECOVA?/Reports/TEXO+CVA+Reports/TEXO_London_B_CVA_Report&ReportMonth=January&ReportYear=2020
WHAT WORKS (From #Nacho in comments, brought here for visibility)
http://slo2000/ReportServer_TECOVA/Pages/ReportViewer.aspx?%2TEXO+CVA+Reports%2fTEXO_London_B_CVA_Report&rs:Command=Render&ReportMonth=January&ReportYear=2020

Routing to a directory with a leading period?

Trying to enable letsencrypt with web2py. As part of that I may need to create a route for a url like www.example.com/.well-known/acme-challenge/<some long string>
As I test this I notice that the following route works:
('/\.well-known/acme-challenge/test.html',
'/some_app/static/well-known/acme-challenge/test.html'),
While this almost identical route doesn't:
('/\.well-known/acme-challenge/test.html',
'/some_app/static/.well-known/acme-challenge/test.html'),
The only difference between these two routes is that in the latter one, in the second element of the tuple, .well-known has a leading period while the former route has well-known without a period.
Note I did try escaping the period like \.well-known but it doesn't work either.
Why does the route with the leading period not work? And how can I fix it?
Even though it is a static URL, the path segment immediately after /static/ is interpreted as the controller function and is therefore expected to be a valid Python identifier (the regular expression used to match that part of the path is \w+).
Note, rather than having web2py serve the letsencrypt response, you might consider configuring your web server to return the response directly (e.g., it is easy to configure Nginx to do this).
I haven't come across a direct solution to the leading period issue (as mentioned by Anthony web2py expects a valid python identifier)
However, to solve the specific problem of working with Let's Encrypt I did follow Anthony's suggestion to handle it in the webserver. I am using Apache, in my httpd.conf I added:
LoadModule alias_module modules/mod_alias.so
Alias "/.well-known/" "/var/www/html/somedirectory/.well-known/"
Note Alias will automatically map whatever comes after the url path. Example with the above Alias:
example.com/.well-known/something/hello
will map to
/var/www/html/somedirectory/.well-known/something/hello

Apache Camel Interceptor with regular expression

This is my route. I want to send a file to an Azure blob. I want to set the name of the blob as the file name without extension. I also want to filter out the whitespaces from the file names. I am thinking of using an interceptor
from("file://C:/camel/source1").recipientList(simple("azure-blob://datastorage/container1/${header.fileName}?credentials=#credentials&operation=updateBlockBlob"))
I want to invoke the interceptor only for updateBlockBlob operatin
interceptSendToEndpoint("^(azure-blob:).+(operation=updateBlockBlob)").setHeader("fileName",simple("${file:onlyname.noext}")).convertBodyTo(File.class)
The above code works with interceptFrom().
I tried replacing the regular expression with wild card like azure* i.e interceptSendToEndpoint("azure*"). It did not work
Whats wrong with the above code? Is it because of recipientList?
Also what features does simple have to remove white space?
Is there a better way to generate blob names dynamically?
Here is the documentation from camel on interceptors.
http://camel.apache.org/intercept.html
interceptFrom that intercepts incoming Exchange in the route.
interceptSendToEndpoint that intercepts when an Exchange is about to
be sent to the given Endpoint.
So I suspect the Exchange is already formed and camel expects the url to be resolved.
So the header needs to be set before the exchange is created for the Azure end point.
I did the following. To set the header, I use the interceptFrom, and to convert the object into File I used the inteceptSendToEndPoint
interceptSendToEndpoint("^(azure-blob:).+(operation=updateBlockBlob)").convertBodyTo(File.class)
interceptFrom().setHeader("fileName",simple("${file:onlyname.noext}".replaceAll("[^a-zA-Z\d]")))
Managed to get rid of the whitespace too

Camel Restlet - Binding query parameters to message headers

Looking through Camel docs I couldn't find any way that allow me to bind the query parameters within the headers. For example :
Let's say I have an endpoint like that
http://localhost:8080/services/resource?filter=xxx
End I want to get that parameter from the header
exchange.getIn.().getHeaders().get('filter')
The query parameter 'filter' is not returned in the header. Anyone of you knows if this feature is coming by default in camel? I know I can build the binding by myself, but i am just looking for choose among camel-servlet (apparently that binding is implemented by default) and camel-restlet.
If you choose camel-restlet you can use the
restletBinding=#refName
to convert the query string parameters to headers.
The #refName is the bean ID of a RestletBinding object in the Camel Registry.

Icinga - How can I set custom contacts for services per hosts

I would like to set different contacts for same service based on from which host the service is called.
I've tried to use macro, but it gets translated only when command is called.
Then I've tried to edit command itself, but I think that variable CONTACTEMAIL is managed internally by icinga. I don't feel comfortable with adding only pure emails to some custom macro defined in HOST.
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Icinga *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
Did anyone try/solve this?
You can define your contact on the host and delete it from services. This way every service in that host will inherit its contacts, if you define a contact again in the service it will ignore the previous one.
If the contacts depends on each service and not host, you will have to define same service for each host/contact.
$CONTACTEMAIL$ is a macro for the contact object, referencing to the attribute "email". Your command "notify-service-by-mail" will be assigned to such a contact as "service_notification_command" and that contact assigned to a service then (or via contactgroup). So once a notification happens, all required information is available and the core will translate the macro $CONTACTEMAIL$ to the real value and pass the converted string to the shell for execution then.
I would go for 2 options
use implied inheritance (http://docs.icinga.org/latest/en/objectinheritance.html), and only define contacts for the host, and not the service below. the configuration parser will recognise that contacts should be inherited and your services will get only the related host's assigned contacts then. Though, this may get ugly in terms of not wanting to notify the host alerts to the same contacts as for the service themselves.
making this more dynamic, i.e. setting service contacts based on their hostname, i would suggest using a config (generation) tool, allowing you e.g. manipulate the service->host relation with the defined contacts then. Though, there seems not really a generic solution out there... I would give LConf a try with the ldap tree itsself, but not sure if this would work out here, rather than writing a custom script, or use some puppet magic.

Resources