Add custom params to prometheus scrape request - configuration

We have metrics endpoint enabled in our application to get metrics. It requires custom parameter, how to configure prometheus.yaml to send custom param as part of each metrics scrape
Below is my prometheus.yml configuration
# Sample METRICS
- job_name: 'sys-metrics'
metrics_path: '/sys/metrics'
# Optional HTTP URL parameters.
params:
-user-id: ['myemail#email.com']
scrape_interval: 3s
static_configs:
- targets: ['dev.devhost.domain.com:12345']
When I start server, I get marshal error
parsing YAML file prometheus.yml: yaml: unmarshal errors:\n line 37: field -user-id not found in type config.plain"
Any help appreciated

under params, user-id is child element, add tab to resolve. as I defined at same level, prometheus expected to be one of pre-defined config.
params:
-user-id: ['myemail#email.com']
Issue solved

Related

Selecting specific JSON fields to use in SNS message

I'm trying to build a step function which receives json as input and then uses only some of this JSON in a message sent via SNS in the step function. I've tried using some of the instrinsic json manipulation functions available but with no luck.
Is there a way to extract specific json fields for an SNS message without using a lambda?
For the message field, I would like the it to be:
message.$: $.name $.questions etc...
But this doesn't work
Here is my code:
stepFunctions:
stateMachines:
hellostepfunc1:
name: test
definition:
Comment: "test"
StartAt: SNSState
States:
SNSState:
Type: Task
InputPath: $
Resource: arn:aws:states:::sns:publish
Parameters:
TopicArn:
Fn::GetAtt: [ MyTopic, TopicArn ]
Message.$: $ //here I would like to send multiple e.g $.name $questions
End: true
The best way is to use an AWS Lambda function. That is, develop a custom AWS Lambda function that can read and manipulate JSON to meet your business requirments using a JSON library. Then hook these Lambda functions into an Amazon States Language document.

SonataUserBundle Api Response returns empty JSON

I'm trying to get the JSON response of SonataUserBundle Api.
So after following the config process from the Sonata HomePage docs
It looks like this API returns an empty object
It looks like you forgot to add metadata directory to jms_serializer config.
jms_serializer:
metadata:
directories:
SonataDatagridBundle:
namespace_prefix: 'Sonata\DatagridBundle\'
path: '#SonataDatagridBundle/Resources/config/serializer'
# Also don't forget to add NewsBundle metadata too
ApplicationSonataNewsBundle:
namespace_prefix: 'Application\Sonata\NewsBundle\'
path: '#ApplicationSonataNewsBundle/Resources/config/serializer'
user class have private members duw to which it can not be accessed. either you need you change it specifier or you can iterate it and store in an array and than you can pass it

How to use advance Ansible playbook conditionals to parse json?

I'm attempting to create a playbook that uses the uri module for creating new watcher tasks in ElasticSearch. However I seem to be getting something wrong with the conditional for checking the register payload as I keep running into the an error; "error while evaluating conditional: payload.contents.find("true") != -1"
What is the correct way to evaluate the returned json from the uri module?
Related files on gist
(btw, I'm running this playbook via vagrant doing provisioning so debugging by dumping the variable playbook is next to impossible and the playbook dies before registering anyways.)
How about something like:
changed_when: (payload.content | from_json).created | bool
Looks like since I'm using the EPEL build, the issue was related to Ansible Pull Request #1011 in that the body_type set to json was not correctly identifying the variable as a string value since the body was being passed to uri as a dictionary instead.
The fix for this was to use lookup('template', '...') instead of a variable

How do I invoke multiple http requests dynamically in jmeter

I have fetched multiple paths of multiple urls from the JSON response using JSON Path extractor in jmeter. The paths are stored in the jmeter variables like url_0,url_1, url_2 and so on. The server IP address is constant.
These urls fetched from the JSON response have to be invoked after parsing the JSON response as stated earlier. How do I achieve this particular behaviour in jmeter?
Use ForEach Controller as it described in Using Regular Expressions in JMeter
If you have variables like:
url_0=/some/path
url_1=/some/other/path
url_2=/some/another/path
etc.
Configure ForEach Controller as follows:
Input Variable Prefix: url
Start index for loop: -1
Output variable name: path
Add "_" before number: check
And use ${path} variable in underlying HTTP Request sampler

What is the difference between jsonrequest and httprequest?

I was checking the files in the controllers of web module in both OpenERP-7.0 and OpenERP-6.1. Then I found that 6.1 uses jsonrequest (#openerpweb.jsonrequest) 7.0 uses httprequest (#openerpweb.httprequest). What is the difference between the two ?
I didn't look at OpenERP v7 but OpenERP v6.1 uses both - HttpRequest and JsonRequest. I suppose it's the same for OpenERP v7...
Both of them are about communication between client and server. HttpRequest communicates trough the well known GET and POST methods. That means the following:
The client send a request encoded in the url (GET method) or in the http body (POST method)
The server returns an object corresponding to the request. Could be an html page, PNG image, CSS file, JavaScript, XML encoded data or whatever.
JsonRequest is an implementation of another protocol for client/server communication - JSON-RPC 2.0. You may want lo look here for more information. It's a remote procedure call (RPC) protocol which means that it allows the client to initiate the execution of some method on the server passing some arguments to this method. In response the client gets some data as a result of the method invocation.
EDIT - some more words about the decorators #openerpweb.jsonrequest and #openerpweb.httprequest
Some methods are decorated with the #openerpweb.jsonrequest decorator, other methods - with the #openerpweb.httprequest. This means nothing else but that the first group of methods will be available for execution trough the JSON RPC protocol and the second group will be accessible trough the pure HTTP protocol.
Now, what is the difference? And do we need both jsonrequest and httprequest? Let simplify it like this: JSON is more suitable for executing methods on the server and obtain results. HTTP is simpler and easier to use when all we what is to access some resource on the server.
Let's 'decorate' this with some examples for clarity. Take a look at the following method of the web.controllers.main.Export class:
#openerpweb.jsonrequest
def formats(self, req):
""" Returns all valid export formats
:returns: for each export format, a pair of identifier and printable name
:rtype: [(str, str)]
"""
...
This method accepts some arguments and returns a list (Python list object) containing all known export formats. It will be called in a programmatic way in some python code on the client side.
On the other side are the 'http' methods - like the method css() of the web.controllers.main.Web class:
#openerpweb.httprequest
def css(self, req, mods=None):
....
All this method does is to return a CSS file to the client. It's a simple action like accessing an image, a HTML web page or whatever other resource on the server. The resource we are returning here is nothing complicated as a Python list as in the previous example. We don't need a special format to encode it additionally. So we don't need additional data encoding format as JSON and remote procedure call protocol as JSON RPC.