Kafka mirrormaker jmxtrans configuration file format - apache-kafka

I use jmxtrans to monitor kafka mirrormaker but my json format seems to have problems, the data can not be displayed
how to write this json file, thank
{
"servers": [{
"port": "5448",
"host": "10.10.21.10",
"queries": [{
"obj": "kafka.consumer:type=ConsumerTopicMetrics,name=BytesInPerSec,topic=mirror_group-*",
"attr": ["Count", "MeanRate", "OneMinuteRate"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "BytesInPerSec"
}
}]
},
{
"obj": "kafka.consumer:type=ConsumerTopicMetrics,name=MessagesInPerSec,topic=mirror_group-*",
"attr": ["Count", "MeanRate", "OneMinuteRate"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "MessagesInPerSec"
}
}]
},
{
"obj": "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestRateAndTimeMs,topic=mirror_group-*",
"attr": ["Count", "Max", "Min", "50thPercentile", "75thPercentile", "95thPercentile"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "ProducerRequestRateAndTimeMs"
}
}]
},
{
"obj": "kafka.producer:type=ProducerRequestMetrics,name=ProducerRequestSize,topic=mirror_group-*",
"attr": ["Count", "Max", "Min", "50thPercentile", "75thPercentile", "95thPercentile"],
"resultAlias": "mirror_group-*",
"outputWriters": [{
"#class": "com.googlecode.jmxtrans.model.output.InfluxDbWriterFactory",
"url": "http://10.10.21.10:8086",
"username": "root",
"password": "123",
"database": "jmxDB",
"tags": {
"application": "ProducerRequestSize"
}
}]
}
]
}]
}
I can't get the data from grafana

Related

KODI JSONRPC Player.GetItem method provide empty details

I start a new video with JSON-RPC call:
{"jsonrpc": "2.0",
"method": "Player.Open",
"params":
{"item":
{"file": "c:\\MyCodes\\samples\\sample-6s.mp4" }},
"id": 1
}
Video started and I want to get the video details and use the following Player.GetItem method:
{
"jsonrpc": "2.0",
"method": "Player.GetItem",
"params": {
"properties": [
"title",
"album",
"artist",
"season",
"episode",
"duration",
"showtitle",
"tvshowid",
"thumbnail",
"file",
"fanart",
"streamdetails"
],
"playerid": 1
},
"id": "VideoGetItem"
}
The problem I got back this:
{
"id": "VideoGetItem",
"jsonrpc": "2.0",
"result": {
"item": {
"album": "",
"artist": [],
"episode": -1,
"fanart": "",
"file": "c:\\MyCodes\\samples\\sample-6s.mp4",
"label": "sample-6s.mp4",
"season": -1,
"showtitle": "",
"streamdetails": {
"audio": [],
"subtitle": [],
"video": []
},
"thumbnail": "",
"title": "",
"tvshowid": -1,
"type": "unknown"
}
}
}
but if I start the same video from KODI GUI I got back this:
{
"id": "VideoGetItem",
"jsonrpc": "2.0",
"result": {
"item": {
"album": "",
"artist": [],
"episode": -1,
"fanart": "",
"file": "C:\\MyCodes\\samples\\sample-6s.mp4",
"label": "sample-6s.mp4",
"season": -1,
"showtitle": "",
"streamdetails": {
"audio": [
{
"channels": 2,
"codec": "mp3",
"language": ""
}
],
"subtitle": [],
"video": [
{
"aspect": 1.3333330154418946,
"codec": "mpeg4",
"duration": 2701,
"hdrtype": "",
"height": 384,
"language": "",
"stereomode": "",
"width": 512
}
]
},
"thumbnail": "image://video#C%3a%5cMyCodes%5csamples%5csample-6s.mp4/",
"title": "",
"tvshowid": -1,
"type": "unknown"
}
}
}
Any idea, or experience? Maybe I should use a different method to get the currently running video details?

Pymongo "and" operator not filtering query results [duplicate]

This question already has answers here:
Retrieve only the queried element in an object array in MongoDB collection
(18 answers)
Closed 25 days ago.
I have this monogdb schema:
groups = {
"bsonType": "object",
"required": [
"created_at", "group_name", "owner",
"members", "currency", "country",
"group_username"
],
"properties": {
"created_at": {
"bsonType": "date",
"description": "The date and time when the group was created"
},
"group_name": {
"bsonType": "string",
"description": "Name of group"
},
"group_username": {
"bsonType": "string",
"description": "groups username"
},
"country": {
"bsonType": "string",
"description": "User's country and is required"
},
"currency": {
"bsonType": "string",
"description": "User's currency type and is required"
},
"description": {
"bsonType": "string",
"description": "Brief description of what the group does"
},
"block": {
"bsonType": "bool",
"description": "Field to check if user disabled from group activity"
},
"owner": {
"bsonType": "object",
"required": ["user_id", "status"],
"properties": {
"user_id": {
"bsonType": "objectId",
"description": "User id of the owner of the group"
},
"status": {
"bsonType": "string",
"description": "Default value is 'owner'",
}
},
},
"group_invite_link": {
"bsonType": "string",
"description": "Link used to invite new members"
},
"members": {
"bsonType": "array",
"items": {
"bsonType": "object",
"required": ["user_id", "name", "status", "confirmed", "joined_at"],
"properties": {
"user_id": {
"bsonType": "objectId"
},
"name": {
"bsonType": "string",
"description": "Name of group member"
},
"status": {
"enum": ["admin", "member"],
"description": "can only be one of the enum values and is required"
},
"confirmed": {
"bsonType": "bool",
"description": "Confirms if user is fully authorized to operate in group"
},
"joined_at": {
"bsonType": "date",
"description": "Date user joined group"
}
}
}
},
"group_wallet_id": {
"bsonType": "objectId",
"description": "Id of wallet associated with group"
}
}
}
and I am querying it to return only documents that match the below query:
db.groups.find({
"$and": [
{
"members.user_id": ObjectId(user_id)
},
{
"members.confirmed": True
}
]
})
It returns this:
{
"sucess": true,
"message": "Users groups",
"data": [
{
"_id": "63987c4263d7eba1e79a1df1",
"created_at": "2022-12-13 13:21:03",
"group_name": "Demo 1",
"is_owner": true,
"balance": {
"$numberDecimal": "250.00"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-13 13:21:03"
},
{
"user_id": "63987b7c63d7eba1e79a1dd8",
"name": "Joy Kudosen",
"status": "member",
"confirmed": true,
"joined_at": "2022-12-14 13:22:03"
},
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-14 11:05:39"
}
]
},
{
"_id": "63987c5a63d7eba1e79a1df4",
"created_at": "2022-12-13 13:21:27",
"group_name": "Demo 2",
"is_owner": true,
"balance": {
"$numberDecimal": "100"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-13 13:21:27"
}
]
},
{
"_id": "6399ae06ebaca8cd5fbcd639",
"created_at": "2022-12-14 11:05:39",
"group_name": "Demo 4",
"is_owner": true,
"balance": {
"$numberDecimal": "0"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-14 11:05:39"
}
]
},
{
"_id": "63d1810699edcb7379f21c27",
"created_at": "2023-01-25 19:20:33",
"group_name": "Hello world",
"is_owner": false,
"balance": {
"$numberDecimal": "0"
},
"members": [
{
"user_id": "63d180c399edcb7379f21c23",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2023-01-25 19:20:33"
},
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "member",
"confirmed": false,
"joined_at": "2023-01-25 19:23:31"
}
]
}
]
}
I want to return only array objects that match the user's id and "confirmed" value of "true" in the members array like this:
{
"sucess": true,
"message": "Users groups",
"data": [
{
"_id": "63987c4263d7eba1e79a1df1",
"created_at": "2022-12-13 13:21:03",
"group_name": "Demo 1",
"is_owner": true,
"balance": {
"$numberDecimal": "250.00"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-13 13:21:03"
},
{
"user_id": "63987b7c63d7eba1e79a1dd8",
"name": "Joy Kudosen",
"status": "member",
"confirmed": true,
"joined_at": "2022-12-14 13:22:03"
},
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-14 11:05:39"
}
]
},
{
"_id": "63987c5a63d7eba1e79a1df4",
"created_at": "2022-12-13 13:21:27",
"group_name": "Demo 2",
"is_owner": true,
"balance": {
"$numberDecimal": "100"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-13 13:21:27"
}
]
},
{
"_id": "6399ae06ebaca8cd5fbcd639",
"created_at": "2022-12-14 11:05:39",
"group_name": "Demo 4",
"is_owner": true,
"balance": {
"$numberDecimal": "0"
},
"members": [
{
"user_id": "63987b7c63d7eba1e79a1dd7",
"name": "Joy Kudosen",
"status": "admin",
"confirmed": true,
"joined_at": "2022-12-14 11:05:39"
}
]
}
]
}
I have used different forms of this query but I am unable to filter out the "hello world" group information. I have tried aggregation and the "or" operation and still get the same results.
"$elemMatch" is used to find documents that match multiple fields within an array element.
For example, like this:
db.groups.find({
"members": {
"$elemMatch": {
"user_id": "63987b7c63d7eba1e79a1dd7",
"confirmed": true
}
}
})
Try it on mongoplayground.net.

Loopback 3: Multiple HasOne relation on one model

So, I opened an issue here, coz in my opinion it should work as I think... but might be wrong so looking for another way
So, pretty much I have two models, Wedding and Person. The Wedding one has these relations set:
"people": {
"type": "hasMany",
"model": "person",
"foreignKey": "",
"options": {
"nestRemoting": true
}
},
"partner1": {
"type": "hasOne",
"model": "person",
"foreignKey": ""
},
"partner2": {
"type": "hasOne",
"model": "person",
"foreignKey": ""
}
And one of my wedding documents looks like this (I am using mongoDB if you cannot tell):
{
"_id": "5de78c76f89d1a8ad4091ca5",
"date": "2019-12-04T10:37:42.000Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7"
}
So, when I set include filter and do:
{ "include": ["partner1", "partner2"]}
in my loopback API explorer on
http://localhost:3000/api/weddings/5de78c76f89d1a8ad4091ca5
I get:
{
"date": "2019-12-04T10:37:42.000Z",
"id": "5de78c76f89d1a8ad4091ca5",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7",
"partner1": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
},
"partner2": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
}
}
But, I am expecting this:
{
"date": "2019-12-04T10:37:42.000Z",
"id": "5de78c76f89d1a8ad4091ca5",
"userId": "5de78c76f89d1a8ad4091ca4",
"created": "2019-12-04T10:37:42.720Z",
"partner1Id": "5de78c77f89d1a8ad4091ca6",
"partner2Id": "5de78c77f89d1a8ad4091ca7",
"partner1": {
"id": "5de78c77f89d1a8ad4091ca6",
"fullName": "Michael Knight",
"spouse": "spouse1",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
},
"partner2": {
"id": "5de78c77f89d1a8ad4091ca7",
"fullName": "Jessica Alba",
"spouse": "spouse2",
"contacts": [],
"verified": false,
"created": "2019-12-04T10:37:43.292Z",
"updated": "2019-12-04T10:37:43.292Z",
"userId": "5de78c76f89d1a8ad4091ca4",
"weddingId": "5de78c76f89d1a8ad4091ca5"
}
}
Any ideas as of why? why do I get the same two records for partner1 and partner2?
Instead of using "hasOne", use "belongsTo".

How to display JSON hash content using rails

Hello I'm new to ruby rails and I'm trying to hardcode to display into my browser the "searched_count" from the phrase "java" from my json hash that I got using an url, which is the following
{
"results": [
{
"_class": "search_log",
"id": 88,
"phrase": "java",
"searched_count": 3758269,
"url": "/courses/search/?q=java"
},
{
"_class": "search_log",
"id": 296,
"phrase": "javascript",
"searched_count": 2385833,
"url": "/courses/search/?q=javascript"
},
{
"_class": "search_log",
"id": 642,
"phrase": "java programming",
"searched_count": 371310,
"url": "/courses/search/?q=java+programming"
},
{
"_class": "search_log",
"id": 6192,
"phrase": "java for complete beginners",
"searched_count": 193568,
"url": "/courses/search/?q=java+for+complete+beginners"
},
{
"_class": "course",
"id": 478878,
"title": "Java Maven: Introduccion paso a paso para no expertos",
"url": "/java-maven/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1325394,
"title": "Java a Profundidad - Temas Avanzados y Desarrollo Web.",
"url": "/java-a-profundidad/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1187500,
"title": "Java EE 7 & Frameworks - JSF2, Spring 4, Struts 2 y EJB3",
"url": "/java-ee-7-frameworks-jsf2-spring-4-struts-2-y-ejb3/",
"type_label": "curso"
},
{
"_class": "course",
"id": 490376,
"title": "Java para Administradores de Sistemas",
"url": "/java-sysadmin/",
"type_label": "curso"
},
{
"_class": "user",
"id": 28097854,
"title": "Javascript Lab",
"name": "Javascript",
"display_name": "Javascript Lab",
"url": "/user/javascript-lab/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 17677946,
"title": "Lara Javalyn",
"name": "Lara",
"display_name": "Lara Javalyn",
"url": "/user/lara-javalyn/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 7708594,
"title": "Ashay Javadekar",
"name": "Ashay",
"display_name": "Ashay Javadekar",
"url": "/user/ashayjavadekar/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 23997368,
"title": "Alex Javad",
"name": "Alex",
"display_name": "Alex Javad",
"url": "/user/alex-javad-2/",
"type_label": "instructor"
}
]
}
I have two methods to try to accomplish this:
require 'sinatra'
require 'net/http'
require 'json'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def get_search_count(term)
url = 'https://www.udemy.com/api-2.0/search-suggestions?q=java'
uri = URI(url)
response = Net::HTTP.get(uri)
return JSON.parse(response)
end
get '/' do
#result = get_search_count "java"
#searchedCount = #result["results"][0]["searched_count"]
"Searched count: #{#searched_count}"
end
When I load my localhost all I get is the phrase "Searched count:" with nothing following, any help identifying my mistakes is greatly appreciated thanks in advance!
You have a typo in the string. You're reading #searched_count rather than #searchedCount

what is the date format from stash api?

In the below json response, what is the date format for createdDate and updatedDate? I am not sure how to work in reverse to find what format the api is using for date. I couldn't find this any where in the documentation.
{
"size": 1,
"limit": 25,
"isLastPage": true,
"values": [
{
"id": 101,
"version": 1,
"title": "Talking Nerdy",
"description": "It’s a kludge, but put the tuple from the database in the cache.",
"state": "OPEN",
"open": true,
"closed": false,
"createdDate": 1359075920,
"updatedDate": 1359085920,
"fromRef": {
"id": "refs/heads/feature-ABC-123",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"toRef": {
"id": "refs/heads/master",
"repository": {
"slug": "my-repo",
"name": null,
"project": {
"key": "PRJ"
}
}
},
"locked": false,
"author": {
"user": {
"name": "tom",
"emailAddress": "tom#example.com",
"id": 115026,
"displayName": "Tom",
"active": true,
"slug": "tom",
"type": "NORMAL"
},
"role": "AUTHOR",
"approved": true
},
"reviewers": [
{
"user": {
"name": "jcitizen",
"emailAddress": "jane#example.com",
"id": 101,
"displayName": "Jane Citizen",
"active": true,
"slug": "jcitizen",
"type": "NORMAL"
},
"role": "REVIEWER",
"approved": true
}
],
"participants": [
{
"user": {
"name": "dick",
"emailAddress": "dick#example.com",
"id": 3083181,
"displayName": "Dick",
"active": true,
"slug": "dick",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": false
},
{
"user": {
"name": "harry",
"emailAddress": "harry#example.com",
"id": 99049120,
"displayName": "Harry",
"active": true,
"slug": "harry",
"type": "NORMAL"
},
"role": "PARTICIPANT",
"approved": true
}
],
"link": {
"url": "http://link/to/pullrequest",
"rel": "self"
},
"links": {
"self": [
{
"href": "http://link/to/pullrequest"
}
]
}
}
],
"start": 0
}
Just making a note that in my case, it is a UNIX timestamp, but I have to remove three trailing zeroes. E.g. the data looks like this:
"createdDate":1555621993000
If interpreted as a UNIX timestamp, that would be 09/12/51265 # 4:16am (UTC).
By removing the three trailing zeroes I get 1555621993, which is the correct time 04/18/2019 # 9:13pm (UTC)
Your mileage may vary but that was a key discovery for me :)
It looks like a UNIX timestamp.
https://en.wikipedia.org/wiki/Unix_time