Get Request Url pattern specific information on Kibana - logstash

I am have a webservice which services GET requests of the following pattern
/v1/stores?name=<>&lat=23&lng=232....
There a number of query parameters which the request can accept. Is it possible to get url specific information kibana through log stash on kibana.What I really want is a average number of requests for each pattern along with their max, min and avg response types.I would also

You would want something like this as part of your logstash.conf:
grok {
// some pattern that extracts out the uri param (everything after ?) into a param field
}
kv {
source => 'param'
field_split => '&'
}
// you might also need to urldecode {} the parameters

Related

How to get current product or category url equivalent for all other channels in shopware 6?

I need to build a "channel switcher" in shopware6. How can I access current (Product)URL equivalents for all or some other channels in this shop? It should work like a language switcher, keeping the current viewed product or category and redirecting to other channel.
I know how to get current seoUrl of product:
{{ seoUrl('frontend.detail.page', { productId: page.product.id }) }}
but is there a way to get all other seoUrls for all other selling channels with the same product.id? And the same for categories?
Rough approach to get all language links
Looking at
\Shopware\Core\Framework\Adapter\Twig\Extension\SeoUrlFunctionExtension which is handling the seoUrl() in twig it looks like this:
public function seoUrl(string $name, array $parameters = []): string
{
return $this->seoUrlReplacer->generate($name, $parameters);
}
This resolves to
\Shopware\Core\Content\Seo\SeoUrlPlaceholderHandler::generate which always uses the current request:
public function generate($name, array $parameters = []): string
{
$path = $this->router->generate($name, $parameters, RouterInterface::ABSOLUTE_PATH);
$request = $this->requestStack->getMainRequest();
$basePath = $request ? $request->getBasePath() : '';
$path = $this->removePrefix($path, $basePath);
return self::DOMAIN_PLACEHOLDER . $path . '#';
}
Which boils down to \Shopware\Storefront\Framework\Routing\Router::generate
As an approach I would suggest to dig into those functions. They directly access the current request and context. Thanks to dependency injection, you can create those instances yourself with the target context and an artificial request containing the right base URL from the target channel.
Approach similar to the language switcher (redirect after POST)
The above approach might be quite complicated, so looking at what the language switcher does:
It just includes the language IDs
On selection posts to \Shopware\Storefront\Controller\ContextController::switchLanguage
Which does the redirect
Example Payload of the request:
languageId: 2fbb5fe2e29a4d70aa5854ce7ce3ff0b
redirectTo: frontend.navigation.page
redirectParameters[navigationId]: a11f6b46948c47a7b2c2ac874704fff6
I think you can extend that script for your channel switcher and add the sales channel id to the request,
then you can reuse / copy or even decorate the switchLanguage controller. You just need to pass in the right context of the target sales channel and it should redirect to the correct URL.

How to change/rename value of kibana index field on kibana UI?

I have set up an ELK stack on one server and filebeat on 2 other servers to send data directly to logstash.
Setup is working fine and I got log result as per need but when I see field sections on Kibana UI (Left side), I see "host.hostname" field which have two servers fqdns (i.e "ip-113-331-116-35.us-east-1.compute.internal",
"ip-122-231-123-35.us-east-1.compute.internal"
)
I want to set alias or rename those value as Production-1 and Production-2 respectively to show on kibana UI
How can I change those values without breaking anything
If you need any code snippet let me know
You can use the translate filter in the filter block of your logstash pipeline to rename the values.
filter {
translate {
field => "[host][hostname]"
destination => "[host][hostname]"
dictionary => {
"ip-113-331-116-35.us-east-1.compute.internal" => "Production-1"
"ip-122-231-123-35.us-east-1.compute.internal" => "Production-2"
}
}
}
Since the field host.hostname is an ECS-field I would not suggest to rename this particular field.
In my opinion you have two choices:
1.) Create a pipeline in Logstash
You can set up a simple pipeline in Logstash where you use the mutate filter plugin and do a add_field operation. This will create a new field on your event with the value of host.hostname. Here's a quick example:
filter{
if [host][hostname]{
mutate{
add_field => { "your_cool_field_name" => "%{[host][hostname]}" }
}
}
}
2.) Setup a custom mapping/index template
You can define field aliases within your custom mappings. I recommend reading this article about field aliases

How to retrieve the #value from message?

i want to retrieve the value from snmptrap input ,
The following log was generated while creating a loop,.
{
"message" => "##enterprise=[1.3.6.1.4.1.9.9.187],#timestamp=##value=2612151602>, #varbind_list=[##name= [1.3.6.1.4.1.9.9.187.1.2.5.1.17.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=\"\x00\x00\">, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.3.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=##value=1>>, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.28.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=\"\">, ##name=[1.3.6.1.4.1.9.9.187.1.2.5.1.29.32.1.14.16.255.255.17.0.0.0.0.0.0.0.0.2], #value=##value=3>>], #specific_trap=7, #source_ip=\"1.2.3.4\", #agent_addr=##value=\"\xC0\xA8\v\e\">, #generic_trap=6>"
}
i want to retrive the value #source_ip from message , i try to use
mutate {
add_field => { "source_ip" =>["#source_ip"] }
}
to get the #souce_ip and for the new field , but still can't get the value ,
If anyone knows how to do with it , please help. Thanks.
The "#source_ip" information is not a field in what you've shown, but rather part of the [message] field. I would guess that the snmptrap{} input is not entirely happy with the message.
Given the example you have, you could run the message through the grok{} filter to pull out the "#source_ip" information.
I stopped using the snmptrap{} input due to other processing issues. I now run snmptrapd and have it write a json log file that is then read by a simple file{} input in logstash.

add/read parameters to/from the url

If I add parameters to the url in the Objective-C code, is it possible to read it from the client?
Example:
- (NSURL *)serverURL {
return [NSURL URLWithString:#"http://rap.eclipsesource.com/demo?parametername=value"];
}
In the Client-JavaCode I can get the value of the parameter like this:
String parameter = RWT.getRequest().getParameter("parametername");
If I access the "app" with the browser I get a value for the parameter. If I access the app with the TabrisClient the value is null.
Is there a way to get the value also in the TabrisClient?
Update:
The server does not directly extract the query string from the request URL, but from the first JSON message received from the client. The web client provides the parameter queryString in the head part of the first UI request. Example:
{
"head": {
"queryString": "foo=23&bar=42",
"requestCounter": ...
},
"operations": [
...
]
}
You would have to fake this behavior in your Tabris client. I'd suggest that you file an issue against Tabris to provide API to set startup parameters.
Original answer:
If you're going to hard-code the parameter in the tabris client anyway, you could set the variable based on the connected client:
parameter = (RWT.getClient() instanceof WebClient)
? RWT.getRequest.getParameter("parametername")
: "tabris-value";
BTW, access to request parameters is going to change in RAP 3.0. Instead of RWT.getRequest().getParameter(), a ClientService will provide the parameters.

The right pattern for returning pagination data with the ember-data RESTAdapter?

I'm displaying a list of articles in a page that are fetched using the Ember Data RESTAdapter. I need to implement a bootstrap'esque paginator (see: http://twitter.github.com/bootstrap/components.html#pagination) and cant seem to find a sane pattern for returning pagination data such as, page count, article count, current page, within a single request.
For example, I'd like the API to return something like:
{
articles: [{...}, {...}],
page: 3,
article_count: 4525,
per_page: 20
}
One idea was to add an App.Paginator DS.Model so the response could look like:
{
articles: [{...}, {...}],
paginator: {
page: 3,
article_count: 4525,
per_page: 20
}
}
But this seems like overkill to hack together for something so trivial. Has anyone solved this problem or found a particular pattern they like? Is there a simple way to manage the RESTAdapter mappings to account for scenarios such as this?
Try to use Ember Pagination Support Mixin and provide your own implementation of the following method. Instead of loading all the content, you can fetch the required content when the user is navigating the pages. All what you need initially is the total account of your records.
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
With ember-data-beta3 you can pass a meta-property in your result. The default RESTSerializer looks for that property and stores it.
You can access the meta-data like this:
var meta = this.get("store").metadataFor("post");
If you are not able to change the JSON returned from the server you could override the extractMeta-hook on the ApplicationSerializer (or any other Model-specific serializer).
App.ApplicationSerializer = DS.RESTSerializer.extend({
extractMeta: function(store, type, payload) {
if (payload && payload.total) {
store.metaForType(type, { total: payload.total }); // sets the metadata for "post"
delete payload.total; // keeps ember data from trying to parse "total" as a record
}
}
});
Read more about meta-data here

Resources