Can't get severity info via API - sonarqube

Java 11
SonarQube 8.9.2 LTS
For my java project the SonarQube show the next issues info:
Severity
Blocker 1.3k
Minor 1.1k
Critical 5.8k
Info 233
Major 1.3k
So I need to get this information via SonarQube WEB API.
I found only this api method:
GET http://some_url_sonar_qube/api/issues/search
And its return all issues on page = 1
And its return all issues on page = 1 with detail info
{
"total": 10049,
"p": 1,
"ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 10049
},
"effortTotal": 50995,
"issues": [
{
"key": "dddd",
"rule": "css:S4670",
"severity": "CRITICAL",
...
This:
GET http://some_url_sonar_qube/api/issues/search?p=2
And its return all issues on page = 2
and so on.
Response example:
As you can see has 10049 issues. It's 100 pages.
But I need summary info. Smt like this in json format:
{
"Severity": {
"Blocker": 1300,
"Minor": 1100,
"Critical": 5800,
"Info": 233,
"Major": 1300
}
}
I'm not found api method for this

I found solution (thanks for #gawkface)
Use this method:
GET http://some_url_sonar_qube/api/issues/search?componentKeys=my_project_key&facets=severities
And here result (on section facets)
{
"total": 10049,
"p": 1,
"ps": 100,
"paging": {
"pageIndex": 1,
"pageSize": 100,
"total": 10049
},
"effortTotal": 50995,
"issues": [...],
"components": [...],
"facets": [
{
"property": "severities",
"values": [
{
"val": "CRITICAL",
"count": 5817
},
{
"val": "MAJOR",
"count": 1454
},
{
"val": "BLOCKER",
"count": 1286
},
{
"val": "MINOR",
"count": 1161
},
{
"val": "INFO",
"count": 331
}
]
}
]
}

Related

ESRI Js API 4.15 : FeatureLayer labels are not visible on all features

I'm trying to show labels on a point FeatureLayer, the label is not visible for just one Feature, But it become visible when the map change scale, is there any explanation?
Here is my code:
"renderer": {
"type": "class-breaks",
"field": "nums",
"classBreakInfos": [
{
"minValue": 0,
"maxValue": 9,
"label": " < 10",
"symbol": {
"type": "picture-marker",
"url": "./assets/picto/nums/vert.png",
"width": 30,
"height": 50
}
},
{
"minValue": 10,
"maxValue": 19,
"label": " 10 à 19",
"symbol": {
"type": "picture-marker",
"url": "./assets/picto/nums/orange.png",
"width": 30,
"height": 50
}
},
{
"minValue": 20,
"maxValue": 1000000,
"label": " > 19",
"symbol": {
"type": "picture-marker",
"url": "./assets/picto/nums/rouge.png",
"width": 30,
"height": 50
}
}
]
},
"labelingInfo": [
{
"labelExpressionInfo": {
"expression": "$feature.nums"
},
"labelPlacement": "center-center",
"symbol": {
"type": "text",
"color": "black",
"haloColor": "white",
"xoffset": -2,
"yoffset": 13,
"font": {
"size": 7,
"family": "sans-serif",
"weight": "bolder"
}
}
}
]
I joined a picture of the FeatureLayer labels problem:
Base on you definition, you are using the default deconflict strategy ("static"). Sometimes when overlaps occurs the overlapped label is not showed. Depends on the situation this strategy make sense or not.
You could try "none" option, to turn off deconfliction and you should not have that issue. It seems it might be what you are looking for.
labelClass.deconflictionStrategy = "none";
ArcGIS JS API - LabelClass deconflictionStrategy

Is possible change priority to task create_snapshot from NORMAL to HIGH or URGENT?

I has a cluster elasticsearch with 6 data nodes and 3 master.
When execute the snapshot I receive the error "process_cluster_event_timeout_exception".
I look in my cluster "/_cat/pending_tasks" it has 69 tasks with priority HIGH and source put-mapping
My cluster is for centralized log and have this process to put data in cluster:
logstash - collect from Redis and put to Elasticsearch
apm-server
filebeat
metricbeat
I stay removing beats and some applications from apm-server
Is possible change priority to task create_snapshot from NORMAL to HIGH or URGENT?
It is not a solution, how to I check the correct size for my cluster?
*Normally i keep 7 days the indice in my cluster because the backup.
But because the error, I removed the process to exclude the old data
GET _cat/nodes?v&s=node.role:desc
ip
heap.percent
ram.percent
cpu
load_1m
load_5m
load_15m
node.role
master
name
10.0.2.8
47
50
0
0.00
0.00
0.00
mi
-
prd-elasticsearch-i-020
10.0.0.7
14
50
0
0.00
0.00
0.00
mi
-
prd-elasticsearch-i-0ab
10.0.1.1
47
77
29
1.47
1.72
1.66
mi
*
prd-elasticsearch-i-0e2
10.0.2.7
58
95
19
8.04
8.62
8.79
d
-
prd-elasticsearch-i-0b4
10.0.2.4
59
97
20
8.22
8.71
8.76
d
-
prd-elasticsearch-i-00d
10.0.1.6
62
94
38
11.42
8.87
8.89
d
-
prd-elasticsearch-i-0ff
10.0.0.6
67
97
25
8.97
10.45
10.47
d
-
prd-elasticsearch-i-01a
10.0.0.9
57
98
32
11.63
9.64
9.17
d
-
prd-elasticsearch-i-005
10.0.1.0
62
96
19
10.45
9.53
9.31
d
-
prd-elasticsearch-i-088
My cluster definitions:
{
"_nodes": {
"total": 9,
"successful": 9,
"failed": 0
},
"cluster_name": "prd-elasticsearch",
"cluster_uuid": "xxxx",
"timestamp": 1607609607018,
"status": "green",
"indices": {
"count": 895,
"shards": {
"total": 14006,
"primaries": 4700,
"replication": 1.98,
"index": {
"shards": {
"min": 2,
"max": 18,
"avg": 15.649162011173184
},
"primaries": {
"min": 1,
"max": 6,
"avg": 5.251396648044692
},
"replication": {
"min": 1,
"max": 2,
"avg": 1.9787709497206705
}
}
},
"docs": {
"count": 14896803950,
"deleted": 843126
},
"store": {
"size_in_bytes": 16778620001453
},
"fielddata": {
"memory_size_in_bytes": 4790672272,
"evictions": 0
},
"query_cache": {
"memory_size_in_bytes": 7689832903,
"total_count": 2033762560,
"hit_count": 53751516,
"miss_count": 1980011044,
"cache_size": 4087727,
"cache_count": 11319866,
"evictions": 7232139
},
"completion": {
"size_in_bytes": 0
},
"segments": {
"count": 155344,
"memory_in_bytes": 39094918196,
"terms_memory_in_bytes": 31533157295,
"stored_fields_memory_in_bytes": 5574613712,
"term_vectors_memory_in_bytes": 0,
"norms_memory_in_bytes": 449973760,
"points_memory_in_bytes": 886771949,
"doc_values_memory_in_bytes": 650401480,
"index_writer_memory_in_bytes": 905283962,
"version_map_memory_in_bytes": 1173400,
"fixed_bit_set_memory_in_bytes": 12580800,
"max_unsafe_auto_id_timestamp": 1607606224903,
"file_sizes": {}
}
},
"nodes": {
"count": {
"total": 9,
"data": 6,
"coordinating_only": 0,
"master": 3,
"ingest": 3
},
"versions": [
"6.8.1"
],
"os": {
"available_processors": 108,
"allocated_processors": 108,
"names": [
{
"name": "Linux",
"count": 9
}
],
"pretty_names": [
{
"pretty_name": "CentOS Linux 7 (Core)",
"count": 9
}
],
"mem": {
"total_in_bytes": 821975162880,
"free_in_bytes": 50684043264,
"used_in_bytes": 771291119616,
"free_percent": 6,
"used_percent": 94
}
},
"process": {
"cpu": {
"percent": 349
},
"open_file_descriptors": {
"min": 429,
"max": 9996,
"avg": 6607
}
},
"jvm": {
"max_uptime_in_millis": 43603531934,
"versions": [
{
"version": "1.8.0_222",
"vm_name": "OpenJDK 64-Bit Server VM",
"vm_version": "25.222-b10",
"vm_vendor": "Oracle Corporation",
"count": 9
}
],
"mem": {
"heap_used_in_bytes": 137629451248,
"heap_max_in_bytes": 205373571072
},
"threads": 1941
},
"fs": {
"total_in_bytes": 45245361229824,
"free_in_bytes": 28231010959360,
"available_in_bytes": 28231011147776
},
"plugins": [
{
"name": "repository-s3",
"version": "6.8.1",
"elasticsearch_version": "6.8.1",
"java_version": "1.8",
"description": "The S3 repository plugin adds S3 repositories",
"classname": "org.elasticsearch.repositories.s3.S3RepositoryPlugin",
"extended_plugins": [],
"has_native_controller": false
}
],
"network_types": {
"transport_types": {
"security4": 9
},
"http_types": {
"security4": 9
}
}
}
}
Data Nodes: 6 instances r4.4xlarge
Master Nodes: 3 instances m5.large
No It is not possible to change priority of task create_snapshot.
As you have 69 pending tasks, it seems you are doing too many mapping updates.
Regarding correct size of cluster, I would recommend you to go through following blog posts :
https://www.elastic.co/blog/found-sizing-elasticsearch
https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/sizing-domains.html

Laravel - Change pagination root url

I am building an API Gateway and I am having a small problem returning the pagination urls from a microservice to the API Gateway.
This is the current structure of my API Gateway:
When I call the microservice, I can easily pass the paging parameters using the request data:
HTTP::get('http://api.billing.microservice.test/v2/invoices', $request->all());
However, when I make a request for a microservice, it returns the requested data, but with the URL of the microservice:
{
"data": [
# data returned from billing microservice with the billing API URL
],
"links": {
"first": "http://api.billing.microservice.test/v2/invoices?page=1",
"last": "http://api.billing.microservice.test/v2/invoices?page=10",
"prev": null,
"next": "http://api.billing.microservice.test/v2/invoices?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 10,
"path": "http://api.billing.microservice.test/v2/invoices",
"per_page": 30,
"to": 30,
"total": 300
}
}
However I need the return to have the main API URL:
{
"data": [
# data returned from billing microservice with the main API Address
],
"links": {
"first": "http://api.main.test/v2/invoices?page=1",
"last": "http://api.main.microservice.test/v2/invoices?page=10",
"prev": null,
"next": "http://api.main.test/v2/invoices?page=2"
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 10,
"path": "http://api.main.test/v2/invoices",
"per_page": 30,
"to": 30,
"total": 300
}
}
Has anyone had to do something similar? What is the best way to achieve the desired results? Do a replace using some kind of regex? Is there anything I can do inside the microservice?
I was able to solve my problem with a simple method that already exists:
Model::paginate()->setPath('http://api.main.microservice.test/v2/invoices');
The result is:
{
"data": [
# data
],
"links": {
"first": "http://api.main.microservice.test/v2/invoices?page=1",
"last": "http://api.main.microservice.test/v2/invoices?page=1",
"prev": null,
"next": null
},
"meta": {
"current_page": 1,
"from": 1,
"last_page": 1,
"path": "http://api.main.microservice.test/v2/invoices",
"per_page": 30,
"to": 3,
"total": 3
}
}

Generating data tables in elastic search

I'm trying to make a data table which consists of some calculations
******************************************************
** Bidder * Request * CPM * Revenue * Response Time **
******************************************************
I've created an index which holds all the data, so my data is stored in following format:
{
"data": {
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 78,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "nits_media_bid_won",
"_type": "nits_media_data_collection",
"_id": "MIyt6m8BWa2IbVphmPUh",
"_score": 1,
"_source": {
"bidderCode": "appnexus",
"width": 300,
"height": 600,
"statusMessage": "Bid available",
"adId": "43d59b34fd61b5",
"requestId": "2c6d19dcc536c3",
"mediaType": "banner",
"source": "client",
"cpm": 0.5,
"creativeId": 98493581,
"currency": "USD",
"netRevenue": true,
"ttl": 300,
"adUnitCode": "/19968336/header-bid-tag-0",
"appnexus": {
"buyerMemberId": 9325
},
"meta": {
"advertiserId": 2529885
},
"originalCpm": 0.5,
"originalCurrency": "USD",
"auctionId": "a628c0c0-bd4d-4f2a-9011-82fab780910e",
"responseTimestamp": 1580190231422,
"requestTimestamp": 1580190231022,
"bidder": "appnexus",
"timeToRespond": 400,
"pbLg": "0.50",
"pbMg": "0.50",
"pbHg": "0.50",
"pbAg": "0.50",
"pbDg": "0.50",
"pbCg": null,
"size": "300x600",
"adserverTargeting": {
"hb_bidder": "appnexus",
"hb_adid": "43d59b34fd61b5",
"hb_pb": "0.50",
"hb_size": "300x600",
"hb_source": "client",
"hb_format": "banner"
},
"status": "rendered",
"params": [
{
"placementId": 13144370
}
],
"nits_account": "asjdfagsd2384vasgd19",
"nits_url": "http://nitsmedia.local/run-ad",
"session_id": "YTGpETKSk2nHwLRB6GbP",
"timestamp": "2020-01-28T05:43:51.702Z",
"geo_data": {
"continent": "North America",
"address_format": "{{recipient}}\n{{street}}\n{{city}} {{region_short}} {{postalcode}}\n{{country}}",
"alpha2": "US",
"alpha3": "USA",
"country_code": "1",
"international_prefix": "011",
"ioc": "USA",
"gec": "US",
"name": "United States of America",
"national_destination_code_lengths": [
3
],
"national_number_lengths": [
10
],
"national_prefix": "1",
"number": "840",
"region": "Americas",
"subregion": "Northern America",
"world_region": "AMER",
"un_locode": "US",
"nationality": "American",
"postal_code": true,
"unofficial_names": [
"United States",
"Vereinigte Staaten von Amerika",
"États-Unis",
"Estados Unidos",
"アメリカ合衆国",
"Verenigde Staten"
],
"languages_official": [
"en"
],
"languages_spoken": [
"en"
],
"geo": {
"latitude": 37.09024000000000143018041853792965412139892578125,
"latitude_dec": "39.44325637817383",
"longitude": -95.7128909999999990532160154543817043304443359375,
"longitude_dec": "-98.95733642578125",
"max_latitude": 71.5388001000000031126546673476696014404296875,
"max_longitude": -66.8854170000000038953658076934516429901123046875,
"min_latitude": 18.77629999999999910187398199923336505889892578125,
"min_longitude": 170.595699999999993679011822678148746490478515625,
"bounds": {
"northeast": {
"lat": 71.5388001000000031126546673476696014404296875,
"lng": -66.8854170000000038953658076934516429901123046875
},
"southwest": {
"lat": 18.77629999999999910187398199923336505889892578125,
"lng": 170.595699999999993679011822678148746490478515625
}
}
},
"currency_code": "USD",
"start_of_week": "sunday"
}
}
},
//Remaining data set....
]
},
}
}
So as per my data set I want to fetch all unique bidderCode (which will be represented as Bidder in the table) and make the data with calculation respective to it. For example
Request - This will be total number of docs count in aggregation
CPM - CPM will be sum of all CPM divided by 1000
Revenue - Total CPM multiplied by 1000
Response time - Average of (responseTimestamp - requestTimestamp)
How can I achieve this, I'm bit confused with it. I tried building the blocks by:
return $this->elasticsearch->search([
'index' => 'nits_media_bid_won',
'body' => [
'query' => $query,
'aggs' => [
'unique_bidders' => [
'terms' => ['field' => 'bidderCode.keyword']
],
'aggs' => [
'sum' => [
'cpm' => [
'field' => 'cpm',
'script' => '_value / 1000'
]
]
],
]
]
]);
But it is showing me error:
{
"error":{
"root_cause":[
{
"type":"x_content_parse_exception",
"reason":"[1:112] [sum] unknown field [cpm], parser not found"
}
],
"type":"x_content_parse_exception",
"reason":"[1:112] [sum] unknown field [cpm], parser not found"
},
"status":400
}
I'm new to this help me out in it. Thanks.
ElasticSearch isn't wrong -- you've swapped the aggregation name with its type. It cannot parse the agg type cpm.
Here's the corrected query:
GET nits_media_bid_won/_search
{
"size": 0,
"aggs": {
"unique_bidders": {
"terms": {
"field": "bidderCode.keyword",
"size": 10
},
"aggs": {
"cpm": { <----------
"sum": { <----------
"field": "cpm",
"script": "_value / 1000"
}
}
}
}
}
}

Create Products using Rest API : Magento V2.0

I have been trying to create a product using Rest API for Magento Version 2.0.
I am using Postman to test the rest api.
URL : http://13.91../rest/V1/products
I have added the following headers to the request.
Authorization : Bearer **********************
Content-Type : application/json
JSON BODY
{
"sku":"10090-White-XL",
"store_view_code":"",
"attribute_set_code":"ColorSize",
"product_type":"virtual",
"categories":"Menswear/Tops",
"product_websites":"base",
"name":"10090-White-XL",
"description":"<p>Precise Long-Sleeve Shirt in Black, Denim, or White.</p>",
"short_description":"",
"weight":"",
"product_online":1,
"tax_class_name":"Taxable Goods",
"visibility":"Not Visible Individually",
"price":119,
"special_price":"",
"special_price_from_date":"",
"special_price_to_date":"",
"url_key":"10090-white-xl",
"meta_title":"Precise Long-Sleeve Shirt",
"meta_keywords":"Precise Long-Sleeve Shirt",
"meta_description":"Precise Long-Sleeve Shirt <p>Precise Long-Sleeve Shirt in Black, Denim, or White.</p>",
"base_image":"",
"base_image_label":"",
"small_image":"",
"small_image_label":"",
"thumbnail_image":"",
"thumbnail_image_label":"",
"swatch_image":"",
"swatch_image_label":"",
"created_at":"3/23/16, 2:15 PM",
"updated_at":"3/23/16, 2:15 PM",
"new_from_date":"",
"new_to_date":"",
"display_product_options_in":"Block after Info Column",
"map_price":"",
"msrp_price":"",
"map_enabled":"",
"gift_message_available":"",
"custom_design":"",
"custom_design_from":"",
"custom_design_to":"",
"custom_layout_update":"",
"page_layout":"",
"product_options_container":"",
"msrp_display_actual_price_type":"",
"country_of_manufacture":"",
"additional_attributes":"color=White,size=XL",
"qty":null,
"out_of_stock_qty":0,
"use_config_min_qty":1,
"is_qty_decimal":0,
"allow_backorders":0,
"use_config_backorders":1,
"min_cart_qty":1,
"use_config_min_sale_qty":1,
"max_cart_qty":10000,
"use_config_max_sale_qty":1,
"is_in_stock":0,
"notify_on_stock_below":1,
"use_config_notify_stock_qty":1,
"manage_stock":0,
"use_config_manage_stock":0,
"use_config_qty_increments":1,
"qty_increments":0,
"use_config_enable_qty_inc":0,
"enable_qty_increments":0,
"is_decimal_divided":0,
"website_id":1,
"related_skus":"",
"crosssell_skus":"",
"upsell_skus":"",
"additional_images":"",
"additional_image_labels":"",
"hide_from_product_page":"",
"bundle_price_type":"",
"bundle_sku_type":"",
"bundle_price_view":"",
"bundle_weight_type":"",
"bundle_values":"",
"configurable_variations":"",
"configurable_variation_labels":"",
"associated_skus":""
}
The error that I get is {"message":"%fieldName is a required field.","parameters":{"fieldName":"product"}}
It will be great if someone could let me know how I could add a product. I have checked all the documents and but could not find an answer.
I have found the answer to my question. The json structure need to be in this format:
{
"product":{
"id": 12345,
"sku": "10090-White-XL",
"name": "10090-White-XL",
"attribute_set_id": 9,
"price": 119,
"status": 1,
"visibility": 1,
"type_id": "virtual",
"created_at": "2016-04-05 23:04:09",
"updated_at": "2016-04-05 23:04:09",
"product_links": [],
"options": [],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "description",
"value": "<p>Precise Long-Sleeve Shirt in Black, Denim, or White.</p>"
},
{
"attribute_code": "meta_title",
"value": "Precise Long-Sleeve Shirt"
},
{
"attribute_code": "meta_keyword",
"value": "Precise Long-Sleeve Shirt"
},
{
"attribute_code": "meta_description",
"value": "Precise Long-Sleeve Shirt <p>Precise Long-Sleeve Shirt in Black, Denim, or White.</p>"
},
{
"attribute_code": "color",
"value": "11"
},
{
"attribute_code": "options_container",
"value": "container2"
},
{
"attribute_code": "required_options",
"value": "0"
},
{
"attribute_code": "has_options",
"value": "0"
},
{
"attribute_code": "url_key",
"value": "10090-white-xl"
},
{
"attribute_code": "msrp_display_actual_price_type",
"value": "0"
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "size",
"value": "8"
}
]
},"saveOptions": true
}
The important thing to note is the product tag in the json.The swagger document help to idenity it. Here is the link to it: http://devdocs.magento.com/swagger/#!/catalogProductRepositoryV1/catalogProductRepositoryV1SavePost
Simple product with custom attributes (ex: remarks).
Just take note of the media_gallery_entries. Make sure to supply a valid base64_encoded_data image content and mime type.
URL: http://domain/index.php/rest/V1/products
METHOD: POST
HEADER:
application/json
Authorization: Bearer
POST DATA / RAW PAYLOAD:
{
"product": {
"sku": "TESTPRD002",
"name": "Women's Running - Pure Boost X Shoes",
"attribute_set_id": 4,
"price": 84,
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2016-12-16 15:20:55",
"updated_at": "2016-12-16 15:20:23",
"weight": 2.5,
"extension_attributes": {
"stock_item": {
"item_id": 1,
"stock_id": 1,
"qty": 20,
"is_in_stock": true,
"is_qty_decimal": false
}
},
"product_links": [],
"options": [],
"media_gallery_entries": [
{
"media_type": "image",
"label": "Women's Running - Pure Boost X Shoes",
"position": 1,
"disabled": false,
"types": [
"image",
"small_image",
"thumbnail"
],
"content": {
"base64_encoded_data": "<ENCODED IMAGE DATA>",
"type": "image/jpeg",
"name": "TESTPRD002-01.jpg"
}
}
],
"tier_prices": [],
"custom_attributes": [
{
"attribute_code": "description",
"value": "<p>Lightweight and sleek, these women's running shoes are fueled by boost™ energy. The low-profile runners blend an energy-returning boost™ midsole with a STRETCHWEB outsole for a cushioned ride with terrific ground-feel. They feature a breathable mesh upper with a sock-like fit that offers all-around support. With a full boost™ midsole that keeps every stride charged with light, fast energy, the shoe has an upper that hovers over a free-floating arch.</p>"
},
{
"attribute_code": "short_description",
"value": "<p>PURE BOOST X SHOES</p><p>NATURAL RUNNING SHOES WITH ARCH SUPPORT.</p>"
},
{
"attribute_code": "meta_title",
"value": "PURE BOOST X SHOES"
},
{
"attribute_code": "meta_keyword",
"value": "boost X, running, shoes, adidas"
},
{
"attribute_code": "meta_description",
"value": "NATURAL RUNNING SHOES WITH ARCH SUPPORT."
},
{
"attribute_code": "category_ids",
"value": [
"2", "3"
]
},
{
"attribute_code": "url_key",
"value": "womens-running-pure-boost-x-shoes"
},
{
"attribute_code": "tax_class_id",
"value": "1"
},
{
"attribute_code": "remarks",
"value": "Lorem ipsum.."
}
]
},
"saveOptions": true
}

Resources