How to use a tag/facet in metrics monitor in datadog? - tags

I added a custom span tag through code to use a custom tag/facet to filter out specific http requests in datadog:
if span, ok := tracer.SpanFromContext(c); ok {
span.SetTag("someTag", someTagValue)
}
In Traces sub-section of APM section, if we click on any http request the tag is appearing with its value as well. I added it as a facet to make it accessible.
I am defining a metrics monitor and trying to use that tag/facet. In "from" section, the tag/facet does not appear in the list to query those requests. Is there a way to use/add such custom tag/facet in metrics monitor? Are the options in "from" section pre-defined?
Other datadog sections I have already explored:
In APM monitors, in "Trace Analytics" section, I am able to access that tag/facet. However, this section does not capture same metrics like requests/sec, errors per requests/sec etc.

Related

Zabbix: how to parse error messages from web scenario checks as a macro

I just setup dozens of web scenario checks in Zabbix. I also added triggers and one action for all the triggers. To test the action I deployed a test bad web scenario check, however an email message I got from the test only gave very high-level information:
Problem: Service "Jira-QAS" is DOWN
------------​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Status: PROBLEM
Value: 1
Original problem ID: 2314429
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
I want to parse "Last error message of scenario ..." as a macro and put it in the "default message" in "Action", so it would look something like this:
Problem: Service "Jira-QAS" is DOWN
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
Application: CloudOps
Problem started at 13:41:38 on 2019.11.20
Problem name: Service "Jira-QAS" is DOWN
Severity: High
Issue: Couldn't connect to server: Failed connect to jira-qas.aws.ca:443; Connection refused
Original problem ID: 2314429
----​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​-------​​​​​​​----​​​​​​​----​​​​​​​----​​​​​​​----
I tried different macros such as {ITEM.VALUE}, {EVENT.STATUS}, but neither of them were good enough.
You need to define Operational Data in the trigger, and add {EVENT.OPDATA} to the mail.
Operational data allow to define arbitrary strings along with macros. The macros will resolve dynamically to real time data in Monitoring → Problems. While macros in the trigger name (see above) will resolve to their values at the moment of a problem happening and will become the basis of a static problem name, the macros in the operational data maintain the ability to display the very latest information dynamically.
The same set of macros is supported as in the trigger name.
https://www.zabbix.com/documentation/current/manual/config/triggers/trigger

IBM Maximo REST service POST not setting attributes on MBO

I have tried to create a record of my customized object through REST service in IBM Maximo.
The problem is that I created the record but I can't assign values to the attributes.
Next I will show what I did and what happened:
I have an Object Structure called oxidato that represents my customized object.
I did a POST using POSTMAN to this URL:
http://hostname:port/maximo/oslc/os/oxidato?lean=1
In the body section this is the JSON I was trying to send:
{
"attribute1":"205",
"attribute2":"206"
}
The record was created but none of the attributes was filled.
In my opinion, the REST service received the POST but can´t read the body.
What am I missing? I add an image of the POSTMAN as example:
EDIT1: I update the POST in order to use the newest API RES (Thanks Dex!)
EDIT2: I add an image of the header
I have found that Maximo will often ignore incoming attributes that aren't in the Maximo namespace (http://www.ibm.com/maximo). You could go through the trouble of setting up your VALOR1 and VALOR2 attributes to be in that namespace, but it's easier to just tell OSLC to ignore namespaces. You do that by setting the "lean" parameter to "1".
In your case, go to the "Params" tab and add an entry with a name of "lean". Give it a value of "1" and then send your POST again. You should see "?lean=1" appear at the end of the POST URL along the top there, but your body content should remain unchanged.
EDIT:
On the other hand, it looks like (based on your URL) that you aren't actually using the newer JSON/OSLC REST API; It looks like you are using the older REST services. This IBM page gives you a lot of information on the newer JSON REST API, including the correct URLs for it: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html.
You should change your URL to /maximo/oslc/os/oxidato to use the newer API that naturally supports JSON and the lean parameter described above. This does required Maximo 7.6 to use though.
EDIT 2:
The attributes are often oddly case sensitive, requiring lowercase. Your example in your question of "attribute1" and "attribute2" are properly lowercase, but your screenshot shows uppercase attribute names. Try changing them to "valor1" and "valor2". Also, these are persistent attributes, right?
The response code received back (e.g. 200 - OK) and the response body will detail the record that was created.
I think you are correct in that the body of the post request is being ignored. Provided there are no required fields on the custom MBO your POST is probably creating an empty record with the next value in the sequence for the key field but you should see that in the response.
The following POST should create a record with values provided for attribute1 and attribute2 and provide a response with the record's identifier so that you can look it up in Maximo and show the values that were stored for attribute1 and attribute2:
http://hostname:port/maximo/rest/os/oxidato/?_format=json&_compact=1&attribute1=205&attribute2=206
Response: 200 OK
Reponse Body:
{ "CreateOXIDATOResponse": {
"rsStart": 0,
"rsCount": 1,
"rsTotal": 1,
"OXIDATOSet": {
"OXIDATO": {
"rowstamp": "[0 0 0 0 0 -43 127 13]",
"ATTRIBUTE1": "205",
"ATTRIBUTE2": "206",
"OXIDATOID": 13
}
} } }
You may also want to turn on debug logging for the REST interface in System Configuration -> Platform Configuration -> Logging for additional detail on what's happening in the log file.

Custom Dimensions Not Reporting Through to Google Analytics API V4

I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,
You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()

How to design complex update actions in REST API

I'm currently working on a REST API, trying to design it with most best practices as possible.
I work with Symfony2 PHP framework but some of my questions are valid for any REST API i guess.
Starting from the base design for a particular resource :
GET /resource - Get all resources
POST /resource - Create resource
GET /resource/{id} - Get resource with id={id}
PUT|PATCH /resource/{id} - Edit the resource with id={id}
DELETE /resource/{id} - Delete the resource with id={id}
Supposing my resource has complex rules while updating.
It has a "status" field, (a float for example), that can be updated only by following a particular scheme
It has a "schedule" field (a datetime), with different choices available that are not always the same
How am I supposed to expose those rules to the API consumer ? For the schedule field, how am I supposed to provide the different choices available at the current time ?
About the Symfony server-side part, I followed most of the recommandations of this walkthrough : http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/
My POST, PUT & PATCH actions are handled with Symfony Forms, so most of the rules are processed by Symfony constraints/validations features.
But form binding is quite limited, let's supposed I want to trigger a particular event if the user change the status field from 2 to 3? What is the best way to do that ?
Thanks in advance.
HTTP has another verb you aren't using: OPTIONS. You can use this to list the schedule options.
Here's a blog article about it: http://zacstewart.com/2012/04/14/http-options-method.html
As for updating the status, I would reuse POST and include an action in the field. Example:
POST
{
"type": "update",
"status": 3
}
Modified REST:
GET /resource - Get all resources
POST /resource - Create resource
GET /resource/{id} - Get resource with id={id}
PUT|PATCH /resource/{id} - Edit the resource with id={id}
DELETE /resource/{id} - Delete the resource with id={id}
OPTIONS /resource/{id} - Retrieve options of resource with id={id}
Keep in mind that you can pass params along in the body for everything but GET and you can pass any params in the URL for GET.
I have zero knowledge on Symfony2, so I'll just concentrate on your more generic REST how-to qustion about exposing rules.
Give the consumers of your REST API a documentation. It's the first thing they will hit before actually playing with your API. Use tools for that, from auto-generated help pages to 3'rd party providers like Apiary.io or alike.
Create meaningful responses when consumers send "wrong" requests: use correct http response status codes (Bad request, Conflict, etc.) when request parameters are missing or invalid.
If your REST api is relaxed, it can also include information about what went wrong and how to resolve the problem in the response body.
What worked well for me in the past was to have a generic ErrorMessage entity that was returned upon each non-successful request, containing a title, an error description, and a dedicated more technical "dev-description" which can be enabled/disabled for test/production on the server side.
In my case, my consumers all know that they can get either the expected response entity in case of success, or that generic ErrorMessage entity in the response in case of failure.
If you can desribe your rules, why not provide those as meta information for your service? Eg. in my case I know I have a set of parameters, each having a set of available options. Think of the parameters as the key in a query string, and the options as the values for that key. In a complex world, parameter options depend on other parameter options, eg. in my case the available options for parameter B are dependent of what option(s) are "selected" for parameter A. I can expose those dependencies by providing a "metadata" resource in my REST api, eg. a JSON stucture listing all parameters and all options for those parameters, and for each option adding a "requires" section desribing that that option is only "available" if parameter xy has selected option p and q.
This allows my consumers to - with a single request to that meta data resource - create a "state-machine" on the client side. I hope you get the picture.
Here is my understanding of REST-full way to handle updates and advertise update operations to API client.
This is based on this wonderful book and Fowler's article about REST with some additions of File Levels of Media Type and article about Restfull CQRS. Basically you use PUT for update and pass the operation via content type and advertise content type via mediaType in hypermedia controls.
All operations which are available for current state of your resource are listed among hypermedia controls which are passed with representation of resource like this:
<myresource>
<status>ACTIVE</status>
<some-field with-attribute="value"/>
<some-other-field/>
<!-- other fields representing state of resource -->
<link rel = "self"
uri = "/resource/1234"/>
<link rel = "/linkrels/resource/changeStatus"
uri = "/resource/1234"
mediaType = "application/vnd.myapp+xml;domain-model=ChangeStatusCommand"/>
<link rel = "/linkrels/resource/changeSchedule"
uri = "/resource/1234"
mediaType = "application/vnd.myapp+xml;domain-model=ChangeScheduleCommand"/>
<link rel = "/linkrels/help"
uri = "/help/resource"/>
</myresource>
Links together with mediaType gives enough information what command is allowed. In many cases this should be something very specific to current state of resource. For example if you can move it from status ACTIVE to TRASHED than command should be named not StatusChange but TrashCommand and so on.

Filter Fiddler traffic

Is it possible to instruct Fiddler to only show me traffic directed to a specific host name?
In other words, can Fiddler traffic be filtered for Host?
See this screenshot. Located at the top right part of the screen
Fiddler's Filters tab can do this - set the 'Hosts' dropdown to 'Show only the following hosts' then put the name in the textbox below.
Go to fiddler script tag and paste following into OnBeforeRequest function. (Screenshot below)
if (oSession.url.Contains("ruby:8080") || oSession.url.Contains("localhost:1234"))
{
oSession["ui-hide"] = "yup"; // "The "yup" value is unimportant"
}
This way you can filter by any part of url be it port, hostname or whatever.
It is useful for filtering out localhost trash as filtering by host alone does not do this...
EDIT as per #baburao comment: Apparently fiddler gives access to process info through the x-ProcessInfo flag. So if you wanna hide a process (say for 'chrome'), change the condition to: if (oSession["x-ProcessInfo"].Contains("chrome"))
Hope this saves you some time.
An alternative is to filter and export session.
You can filter by typing in the bottom black box area with prefix # and your hostname. eg, #msn.com
Fiddler documentation has good sample. http://docs.telerik.com/fiddler/knowledgebase/QuickExec