Related
Does somebody knows why Twitter API delivers different information for the same status using different methods?
I'm working on a Twitter bot to collect transit events. I'm facing some issues with the information delivered by the API, due to I've identified that depending on the method, the API can deliver different result for the same Tweet/status.
Here an example for the Tweet ID:1531517617562951682 using api.get_status, the status doesn't have the attributes extended_tweet and timestamp_ms.
Thanks in advance.
{
"created_at": "Tue May 31 06:07:08 +0000 2022",
"id": 1531517617562951682,
"id_str": "**1531517617562951682**",
"text": "01:07 #Precauci\u00f3nVial | Por percance en Av. Ing. Eduardo Molina a la altura de Av. Talism\u00e1n, col. San Pedro el Chic\u2026 (**removed_url)",
**"truncated": true**,
"entities": {
"hashtags": [
{
"text": "Precauci\u00f3nVial",
"indices": [
6,
21
]
}
],
"symbols": [],
"user_mentions": [],
"urls": [
{
"url": **removed_url_short,
"expanded_url": ,
"display_url": ,
"indices": [
117,
140
]
}
]
},
"source": "Twitter Web App",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 166594238,
"id_str": "166594238",
"name": "OVIAL_SSCCDMX",
"screen_name": "OVIALCDMX",
"location": "Liverpool #136, Col. Ju\u00e1rez",
"description": "Centro de Orientaci\u00f3n Vial de la Secretar\u00eda de Seguridad Ciudadana de la Ciudad de M\u00e9xico.",
"url":,
"entities": {
"url": {
"urls": [
{
"url": ,
"expanded_url": ,
"display_url": "ssc.cdmx.gob.mx",
"indices": [
0,
23
]
}
]
},
"description": {
"urls": []
}
},
"protected": false,
"followers_count": 1866313,
"friends_count": 125,
"listed_count": 4188,
"created_at": "Wed Jul 14 15:00:43 +0000 2010",
"favourites_count": 2748,
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"verified": true,
"statuses_count": 1110675,
"lang": null,
"contributors_enabled": false,
"is_translator": false,
"is_translation_enabled": false,
"profile_background_color": "000000",
"profile_background_image_url":
"profile_background_image_url_https": ,
"profile_background_tile": false,
"profile_image_url": ,
"profile_image_url_https": ,
"profile_banner_url": ,
"profile_link_color": "BC8F8F",
"profile_sidebar_border_color": "000000",
"profile_sidebar_fill_color": "000000",
"profile_text_color": "000000",
"profile_use_background_image": false,
"has_extended_profile": false,
"default_profile": false,
"default_profile_image": false,
"following": false,
"follow_request_sent": false,
"notifications": false,
"translator_type": "none",
"withheld_in_countries": []
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 0,
"favorite_count": 0,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"possibly_sensitive_appealable": false,
"lang": "es"
}
Same status collected with a stream.Attributes extended_tweet and timestamp are present on the status:
{
"created_at": "Tue May 31 06:07:08 +0000 2022",
"id": 1531517617562951682,
"id_str": "1531517617562951682",
"text": "01:07 #Precauci\u00f3nVial | Por percance en Av. Ing. Eduardo Molina a la altura de Av. Talism\u00e1n, col. San Pedro el Chic\u2026 (**removed url)",
"display_text_range": [
0,
140
],
"source": "Twitter Web App",
"truncated": true,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 166594238,
"id_str": "166594238",
"name": "OVIAL_SSCCDMX",
"screen_name": "OVIALCDMX",
"location": "Liverpool #136, Col. Ju\u00e1rez",
"url": "http://ssc.cdmx.gob.mx",
"description": "Centro de Orientaci\u00f3n Vial de la Secretar\u00eda de Seguridad Ciudadana de la Ciudad de M\u00e9xico.",
"translator_type": "none",
"protected": false,
"verified": true,
"followers_count": 1866203,
"friends_count": 125,
"listed_count": 4188,
"favourites_count": 2748,
"statuses_count": 1110325,
"created_at": "Wed Jul 14 15:00:43 +0000 2010",
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"lang": null,
"contributors_enabled": false,
"is_translator": false,
"profile_background_color": "000000",
"profile_background_image_url": ,
"profile_background_image_url_https": ,
"profile_background_tile": false,
"profile_link_color": "BC8F8F",
"profile_sidebar_border_color": "000000",
"profile_sidebar_fill_color": "000000",
"profile_text_color": "000000",
"profile_use_background_image": false,
"profile_image_url": ,
"profile_image_url_https": ,
"profile_banner_url": ,
"default_profile": false,
"default_profile_image": false,
"following": null,
"follow_request_sent": null,
"notifications": null,
"withheld_in_countries": []
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"extended_tweet": {
"full_text": "01:07 #Precauci\u00f3nVial | Por percance en Av. Ing. Eduardo Molina a la altura de Av. Talism\u00e1n, col. San Pedro el Chico, servicios de emergencia acuden al lugar. (**removed url)",
"display_text_range": [
0,
158
],
"entities": {
"hashtags": [
{
"text": "Precauci\u00f3nVial",
"indices": [
6,
21
]
}
],
"urls": [],
"user_mentions": [],
"symbols": [],
"media": [
{
"id": 1531517217703092224,
"id_str": "1531517217703092224",
"indices": [
159,
182
],
"additional_media_info": {
"monetizable": false
},
"media_url": ,
"media_url_https": ,
"url":,
"display_url": "pic.twitter.com/q3seKvyPIM",
"expanded_url": ,
"type": "video",
"video_info": {
"aspect_ratio": [
16,
9
],
"duration_millis": 4003,
"variants": [
{
"content_type": "application/x-mpegURL",
"url": ""
},
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "
},
{
"bitrate": 256000,
"content_type": "video/mp4",
"url":
}
]
},
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"large": {
"w": 640,
"h": 360,
"resize": "fit"
},
"medium": {
"w": 640,
"h": 360,
"resize": "fit"
},
"small": {
"w": 640,
"h": 360,
"resize": "fit"
}
}
}
]
},
"extended_entities": {
"media": [
{
"id": 1531517217703092224,
"id_str": "1531517217703092224",
"indices": [
159,
182
],
"additional_media_info": {
"monetizable": false
},
"media_url": ,
"media_url_https": ,
"url": ,
"display_url": ,
"expanded_url": ,
"type": "video",
"video_info": {
"aspect_ratio": [
16,
9
],
"duration_millis": 4003,
"variants": [
{
"content_type": "application/x-mpegURL",
"url": "
},
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "
},
{
"bitrate": 256000,
"content_type": "video/mp4",
"url": ""
}
]
},
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"large": {
"w": 640,
"h": 360,
"resize": "fit"
},
"medium": {
"w": 640,
"h": 360,
"resize": "fit"
},
"small": {
"w": 640,
"h": 360,
"resize": "fit"
}
}
}
]
}
},
"quote_count": 0,
"reply_count": 0,
"retweet_count": 0,
"favorite_count": 0,
"entities": {
"hashtags": [
{
"text": "Precauci\u00f3nVial",
"indices": [
6,
21
]
}
],
"urls": [
{
"url": ,
"expanded_url": ,
"display_url": "twitter.com/i/web/status/1\u2026",
"indices": [
117,
140
]
}
],
"user_mentions": [],
"symbols": []
},
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"filter_level": "low",
"lang": "es",
"**timestamp_ms**": "1653977228905"
}
For v1.1, the extended Tweet information is available by default in the streaming API, but for the REST endpoints, you need to add the tweet_mode=extended parameter to your request to retrieve the full text.
In V2, there is no longer a concept of extended (beyond 140 characters) Tweets. All Tweets are natively up to 280 characters as standard.
Is it possible to use jsPDF to grab text from a HTML page and jsPDF-autotable to grab the table and to get that all inside one PDF? I have a document which has some content, and tables in the middle of the content. However, I was not able to print that document.
Sample code:
Sample code:enter code here
In the below code I am looping my Content array. Content can be of different types. For the table content am trying to use pdf.autoTable and for the text content am using pdf.text
var pdf = new jspdf('p', 'pt', 'a4');
pdf.setFontSize(18);
pdf.line(20, 25, 25, 25);
for (let i = 0; i < this.dalSectionsArray.length; i++) {
dynamicHtmlSource = dynamicHtmlSource + '<p style="text-align:left;">
<b>' + this.dalSectionsArray[i].title + '</b></p><b/>';
pdf.text(dynamicHtmlSource, 10+i, 10+i);
for (let j = 0; j < this.dalContentsArray.length; j++) {
if (this.dalSectionsArray[i].id ===
this.dalContentsArray[j].sectionView.id) {
if (this.dalContentsArray[j].subType === 'Clause') {
dynamicHtmlSource = this.getClauseData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,20+j,20+j);
} else if (this.dalContentsArray[j].subType === 'Block') {
dynamicHtmlSource = this.getBlockData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource,30+j,30+j);
} else if (this.dalContentsArray[j].subType === 'Restriction') {
dynamicHtmlSource =
this.getRestrictionData(this.dalContentsArray[j]);
pdf.text(dynamicHtmlSource, 40+j, 40+j);
} else if (this.dalContentsArray[j].subType === 'Table') {
pdf.autoTable({
startY:50+j,
columnStyles: { europe: { halign: 'center' } }, // European
countries centered
body: this.dalContentsArray[j].tableValues,
columns: this.dalContentsArray[j].displayColumns
})
}
}
pdf.fromHTML('',
this.margins.left, // x coord
this.margins.top,
{
// y coord
width: this.margins.width// max width of content on PDF
}, (dispose) => {
this.headerFooterFormatting(pdf, pdf.internal.getNumberOfPages());
},
this.margins);
var iframe = document.createElement('iframe');
iframe.setAttribute('style', 'position:absolute;right:0; top:0;
bottom:0; height:100%; width:650px; padding:20px;');
document.body.appendChild(iframe);
pdf.setProperties({
title: 'jspdf-iframe',
subject: 'DAL Content',
author: 'PDFAuthor',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'ABC'
});
iframe.src = pdf.output('datauristring');
Issue is the pdf is completely messed and not printed properly. Can any
one help me in this regard.
Sample JSON:
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"sections": [
{
"title": "ABC",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"_etag": "\"0d0006a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "DEF",
"description": "",
"order": "2",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"_etag": "\"0d0004a2-0000-0c00-0000-5c94e5760000\"",
"partitionKey": "GGG-Section-{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
},
{
"title": "GHI",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"_etag": "\"0d00faa1-0000-0c00-0000-5c94e5750000\"",
"partitionKey": "GGG-Section-{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"type": "Section",
"clientId": "GGG",
"createdBy": "FFFFF",
"createdDate": "2018-11-12T00:00:00",
"modifiedBy": "FFFFF",
"modifiedDate": "2018-11-12T00:00:00",
"isactive": false
}
],
"contents": [
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{a351366f-bf4b-44e0-94ff-a81be899ec3a}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "AAA",
"description": "",
"order": "4"
},
"title": "PL",
"description": "",
"order": "3",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "M", "O", "P" ],
"tableValues": [
{
"N": "Level 21",
"M": "22",
"O": "",
"P": "",
"isRowEditable": false
},
{
"id": "6cb79b9f-2ef2-4d3a-b6c4-7d84dd61aaf7",
"isDeleted": true,
"N": "KKKKKKK",
"M": "GBP 20M",
"O": "",
"isRowEditable": false
},
{
"id": "c83caf0b-8f00-4dc8-bf35-473bda398937",
"isDeleted": true,
"N": "EP",
"M": "GBP 15M",
"O": "",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"_etag": "\"0d00a0ca-0000-0c00-0000-5c94ef3f0000\"",
"partitionKey": "GGG-CCCCOOOOO-{16a3fb1e-f7fa-4dfe-a4d3-c51b56c8dbee-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{2b498850-8f11-475d-b170-5705d05c4bf1}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "kkkkk",
"Description": [
{
"type": "label",
"value": "<br/>Some sample text here"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"_etag": "\"0d00a5ca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{6193cef1-2fe5-47c2-8367-0650ab66caf3-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{d6793120-5e5b-40ec-a1ea-e82e7bdc9d1a}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "UT",
"description": "Sample Text",
"order": "4"
},
"title": "PR",
"Description": [
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "any one programme/risk</li><li>a maximum premium of "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "<br/>SSample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": "Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ".Sample"
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of Canadian domiciled Property risks<br/>Your authority for Health extends to unlimited Healthcare where required by statute<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of declarations under the Coast P&I Facility<br/>You may accept up to "
},
{
"type": "dropDown",
"value": "USD",
"options": [ "USD", "INR", "Dollar" ]
},
{
"type": "text",
"value": "50"
},
{
"type": "label",
"value": ", on Lloyd's paper, in respect of combined primary and excess grounding liability<br/>"
}
],
"order": "6",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"_etag": "\"0d00acca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{22505164-4d56-493e-8df2-b1bb53ab419a-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{ac949799-60c7-4f85-840f-f30203c5ee43}-{1}",
"subType": "Block",
"sectionView": {
"id": "{fca09906-dff9-40b2-a971-28fef7f37dbf}-{1}",
"title": "GR",
"description": "",
"order": "2"
},
"title": "",
"description": "Sample",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"_etag": "\"0d00baca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{8652fedc-0d7c-48d8-bc3f-577294551671-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{522f1248-0882-4348-9bba-59c056c816c8}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "UP",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"_etag": "\"0d00bfca-0000-0c00-0000-5c94ef400000\"",
"partitionKey": "GGG-CCCCOOOOO-{944eae3d-fa0f-4b0e-9c66-3499a16fc2fd-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{6c6a3c80-3536-4c51-8ccf-fcdc16d94090}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PT",
"description": "",
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ ".", "KKKKKKK", "EP", "P" ],
"tableValues": [
{
".": "Level 11",
"KKKKKKK": "",
"EP": "Level 21",
"P": "",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Auto manufacturing - safety critical components",
"KKKKKKK": "GBP 10M",
"EP": ".",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": "GBP 5M",
"EP": ".",
"isRowEditable": false
},
{
".": "Asbestos - other than licensed removers",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
},
{
".": "Rail - contracting companies",
"KKKKKKK": ".",
"EP": "GBP 10M",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": "."
}
],
"id": "{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"_etag": "\"0d00c5ca-0000-0c00-0000-5c94ef410000\"",
"partitionKey": "GGG-CCCCOOOOO-{91de8a0b-4156-4121-be05-844b03928c29-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "9",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"_etag": "\"0d00e3ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw-per}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92860693-e038-4a58-814c-6a74d59e7cce}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "PL",
"Description": [
{
"type": "label",
"value": "Sample"
}
],
"order": "7",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"_etag": "\"0d00e8ca-0000-0c00-0000-5c94ef420000\"",
"partitionKey": "GGG-CCCCOOOOO-{af17341e-a88c-4564-8296-c513e3708af2-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{92c5bd05-c8a2-45c1-a1e9-fd3f78c705ab}-{1}",
"subType": "Table",
"sectionView": {
"id": "{9cfb60cf-354c-4194-9e2e-6bab41c6b280}-{1}",
"title": "KKPKPKPK",
"description": "",
"order": "4"
},
"title": "KKPKPKPK PP",
"description": "",
"order": "1",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [ "N", "kkk", "LPLPLPL", "Ccy", "M", "LTLT", "P" ],
"tableValues": [
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "Level 11",
"kkk": "",
"LPLPLPL": "",
"Ccy": "",
"M": "11",
"LTLT": "",
"P": "",
"isRowEditable": false
},
{
"N": "QQQl",
"kkk": "QQQQ",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "10M",
"LTLT": "Any one vessel",
"isRowEditable": false
},
{
"N": "Marine Cargo",
"kkk": "QIEL",
"LPLPLPL": "Lineslip and other non-coverholder facilities",
"Ccy": "GBP",
"M": "5M",
"LTLT": "Any one event",
"isRowEditable": false
},
{
"N": "KKKK",
"kkk": "PPPP",
"LPLPLPL": "DDDD",
"Ccy": "GBP",
"M": "20M",
"LTLT": "Any one vessel",
"isRowEditable": false
}
],
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"_etag": "\"0d00eacb-0000-0c00-0000-5c94ef530000\"",
"partitionKey": "GGG-CCCCOOOOO-{d036bc60-db2d-4c93-86ff-981a62e207ca-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
},
{
"dalId": "{QQ-4b3544ef-3821-439c-84cf-b6f18c9a86fc-uw}-{1}",
"baseDataid": "{bf1f6e82-6afd-4837-81ab-acabc665da14}-{1}",
"subType": "Clause",
"sectionView": {
"id": "{b3cdda34-1fd2-4463-9aa0-24beff4b83fe}-{1}",
"title": "LLL",
"description": "",
"order": "3"
},
"title": "klklkl",
"Description": [
{
"type": "label",
"value": "sAMPLE tEXT"
}
],
"order": "4",
"status": "Active",
"startDate": "2018-12-12T00:00:00",
"endDate": null,
"displayColumns": [],
"tableValues": null,
"placeHolderValues": "",
"organizationDataView": [
{
"id": "{8b958d63-d605-4b9a-a3c4-a3c1c052316e}-{1}",
"orgGroupName": "QQ",
"orgGroupType": "DD",
"orgLevel": 1,
"orgParentGroupId": ""
}
],
"id": "{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"_etag": "\"0d0062cc-0000-0c00-0000-5c94ef5a0000\"",
"partitionKey": "GGG-CCCCOOOOO-{QQ-851f96e7-542f-4a57-a0b1-35feb4698f5e-uw}-{1}",
"type": "CCCCOOOOO",
"clientId": "GGG",
"createdBy": "MM",
"createdDate": "2018-12-12T00:00:00",
"modifiedBy": "PPP",
"modifiedDate": null,
"isactive": false
}
]
}
getClauseData(dalContentdata) {
let dynamicClauseHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + '<p></p>';
dynamicClauseHtmlSource = dynamicClauseHtmlSource + + '<p style="text-align:justify;line-height:0.3em">' + dalContentdata.description + '</p>';
dynamicClauseHtmlSource = this.brToNewLine(dynamicClauseHtmlSource);
return dynamicClauseHtmlSource;
}
getBlockData(dalContentdata) {
let dynamicBlockHtmlSource = '<h4>' + dalContentdata.title + '</h4>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + '<p></p>';
dynamicBlockHtmlSource = dynamicBlockHtmlSource + dalContentdata.description;
dynamicBlockHtmlSource = this.brToNewLine(dynamicBlockHtmlSource);
return dynamicBlockHtmlSource;
}
getTableData(dalContentdata) {
let tableSource = "<table>";
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<th style='word-wrap: break-word'>" + dalContentdata.displayColumns[k] + "</th>";
}
tableSource = tableSource + "</tr>";
for (var j = 0; j < dalContentdata.tableValues.length; j++) {
tableSource = tableSource + "<tr>";
for (var k = 0; k < dalContentdata.displayColumns.length; k++) {
tableSource = tableSource + "<td style='word-wrap: break-word'>" + dalContentdata.tableValues[0][dalContentdata.displayColumns[k]] + "</td>";
}
tableSource = tableSource + "</tr>";
}
tableSource = tableSource + "</table>";
return tableSource;
}
brToNewLine(str) {
return str.replace(/<br ?\/?>/g, "\n");
}
I have a grafana docker image which have hawkular-datasource pre-configured using configuration files.
After after running grafana instance, I have a json given by teammate, which can be imported inside grafana and that json file creates dashboard when imported.
How do I make that dashboards appear by default in Grafana instance?
I tried copying the json file to /etc/grafana/provisioning/dashboards/ folder and created a new docker image. But when I run the image, the instance doesn't contain the dashboard at the homepage or anywhere in it.
How do I add this json file in docker image. Am I following the correct way?
I tried this http://docs.grafana.org/administration/provisioning/ But it didn't help out much. Any suggestion?
Here is the json file.
{
"id": null,
"title": "Openshift Metrics",
"tags": [],
"style": "dark",
"timezone": "browser",
"editable": true,
"hideControls": false,
"sharedCrosshair": false,
"rows": [
{
"collapse": false,
"editable": true,
"height": "322px",
"panels": [
{
"content": "<center><p style='font-size: 40pt'>$app</p></center>",
"editable": true,
"error": false,
"id": 23,
"isNew": true,
"links": [],
"mode": "html",
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"style": {
"font-size": "36pt"
},
"title": "",
"type": "text"
},
{
"aliasColors": {},
"bars": false,
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"fill": 1,
"grid": {
"threshold1": null,
"threshold1Color": "rgba(216, 200, 27, 0.27)",
"threshold2": null,
"threshold2Color": "rgba(234, 112, 112, 0.22)"
},
"id": 9,
"isNew": true,
"legend": {
"avg": false,
"current": false,
"max": false,
"min": false,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 2,
"links": [],
"nullPointMode": "connected",
"percentage": false,
"pointradius": 5,
"points": false,
"renderer": "flot",
"repeatIteration": 1476706310439,
"scopedVars": {},
"seriesOverrides": [],
"span": 6,
"stack": false,
"steppedLine": false,
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "none",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "avg",
"type": "gauge"
}
],
"timeFrom": null,
"timeShift": null,
"title": "Memory usage",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"show": true
},
"yaxes": [
{
"format": "bytes",
"label": null,
"logBase": 1,
"max": null,
"min": 0,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
]
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 12,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "sum",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "live",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Live, all pods",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 15,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "avg",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "live",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Live per pod",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 10,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "sum",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "avg",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Average, all pods",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 13,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "avg",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "avg",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Average per pod",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 11,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "sum",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "max",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Max, all pods",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
},
{
"cacheTimeout": null,
"colorBackground": true,
"colorValue": false,
"colors": [
"rgba(50, 172, 45, 0.97)",
"rgba(237, 129, 40, 0.89)",
"rgba(245, 54, 54, 0.9)"
],
"datasource": "Hawk-DS",
"editable": true,
"error": false,
"format": "bytes",
"gauge": {
"maxValue": 100,
"minValue": 0,
"show": false,
"thresholdLabels": false,
"thresholdMarkers": true
},
"height": "100px",
"id": 14,
"interval": null,
"isNew": true,
"links": [],
"mappingType": 1,
"mappingTypes": [
{
"name": "value to text",
"value": 1
},
{
"name": "range to text",
"value": 2
}
],
"maxDataPoints": 100,
"nullPointMode": "connected",
"nullText": null,
"postfix": "",
"postfixFontSize": "50%",
"prefix": "",
"prefixFontSize": "50%",
"rangeMaps": [
{
"from": "null",
"text": "N/A",
"to": "null"
}
],
"repeatIteration": 1476706310439,
"scopedVars": {},
"span": 2,
"sparkline": {
"fillColor": "rgba(31, 118, 189, 0.18)",
"full": false,
"lineColor": "rgb(31, 120, 193)",
"show": false
},
"targets": [
{
"queryBy": "tags",
"rate": false,
"refId": "A",
"seriesAggFn": "avg",
"tags": [
{
"name": "container_name",
"value": "$app"
},
{
"name": "descriptor_name",
"value": "memory/usage"
}
],
"target": "select metric",
"tagsQL": "container_name IN [$app] AND descriptor_name='memory/usage'",
"timeAggFn": "max",
"type": "gauge"
}
],
"thresholds": "140000000,180000000",
"title": "Max per pod",
"type": "singlestat",
"valueFontSize": "80%",
"valueMaps": [
{
"op": "=",
"text": "N/A",
"value": "null"
}
],
"valueName": "avg"
}
],
"repeat": "app",
"scopedVars": {
"app": {
"text": "aloha",
"value": "aloha",
"selected": true
}
},
"title": "New row"
}
],
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"1m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"templating": {
"list": [
{
"current": {},
"datasource": "Hawk-DS",
"hide": 0,
"includeAll": true,
"label": "Application",
"multi": true,
"name": "app",
"options": [],
"query": "tags/container_name:*",
"refresh": 1,
"regex": "",
"type": "query"
}
]
},
"annotations": {
"list": []
},
"schemaVersion": 12,
"version": 32,
"links": [],
"gnetId": null
}
You should put a YAML file pointing to the JSON files in that folder. For example write /etc/grafana/provisioning/dashboards/local.yml:
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10 #how often Grafana will scan for changed dashboards
options:
path: /var/lib/grafana/dashboards
And then write your JSON file to /var/lib/grafana/dashboards/openshift.json.
Before Grafana 5, my previous solution was to wrap the whole Docker process in a script that uses the API to create the dashboard once the Docker container is up. You can use the GF_SECURITY_ADMIN_PASSWORD environment variable to set the password. You can also use GF_AUTH_ANONYMOUS_ENABLED, but you'll need to make sure it's not accessible to the outside world.
docker run -p 3000:3000 -e GF_AUTH_ANONYMOUS_ENABLED=true grafana/grafana ...
sleep 10 # wait for grafana to load (use a better method of waiting in production)
curl -skfS -XPOST --header "Content-Type: application/json" "http://localhost:3000/grafana/api/dashboards/db" --data-binary #dashboard.json
I've faced with the same problem and I hope the next solution could help somebody.
For example, you have the next working directory:
├── docker-compose.yml
├── grafana
│ ├── Dockerfile
│ ├── dashboards
│ │ └── exported_dashboard.json #dashboard you saved before
│ └── provisioning
│ │
│ ├── dashboards
│ │ └── all.yml
│ └── datasources
│ └── all.yml
In the Dockerfile you have to add provisioning and dashboards folders into grafana container:
FROM grafana/grafana:latest
ADD ./provisioning /etc/grafana/provisioning
ADD ./dashboards /var/lib/grafana/dashboards
In provisioning/dashboards/all.yml you have to set path to imported dashboards folder
where exported_dashboard.json is actually placed:
- name: 'default'
org_id: 1
folder: ''
type: 'file'
options:
folder: '/var/lib/grafana/dashboards'
[Optional] Then you also can configure default datasourse in provisioning/datasources/all.yml, prometheus, for example:
datasources:
- access: 'proxy'
editable: true
is_default: true
name: 'prom1'
org_id: 1
type: 'prometheus'
url: 'http://prometheus:9090'
version: 1
Finally, docker-compose.yml:
version: '3.8'
services:
grafana:
image: awesome-grafana:latest
build:
context: grafana
ports:
- "3000:3000"
environment:
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: "/var/lib/grafana/dashboards/exported_dashboard.json"
As for HOME dashborad, you can use the GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH evironment variable, as shown above.
More about GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH evironment variable you can read in that github issue.
The full comprehensive code example you can find in the next github repository
Original article with explanation there.
**
i was trying to load woo commerce product list in my collection view.
i am gating data from server also able to print data. but when i go to
showing data in my collection view cell it's not showing.
**
here what i have done
var newArraivalArray = [AnyObject]()
Here i try to get Json data array
Alamofire.request("https://infinitymegamall.com/wp-json/wc/v2/products?after=2016-12-19T16:39:57-08:00", parameters:
["consumer_key":"*******", "consumer_secret":"*******"])
.responseJSON{ response in
if let json = response.result.value {
newArraivalArray = json as! [AnyObject]
print(json)
}
self.collectionView.reloadData()
}
for number of item in collectionview
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return newArraivalArray.count
}
for showing data in collection view.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cellC = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath as IndexPath) as! NewArraivelCollectionViewCell
let productName = newArraivalArray[indexPath.row]["name"]
cellC.name.text = productName as? String
return cellC
}
but i did't see any data in my collection view cell.but some how product name is not showing in my cell. i have no idea what happening.
here what error i get
Here is my json Data
[
{
"id": 57678,
"name": "Mens Formal Printed Shirt",
"slug": "mens-formal-printed-shirt-3",
"permalink": "https://infinitymegamall.com/product/mens-formal-printed-shirt-3/",
"date_created": "2018-01-10T18:29:58",
"date_created_gmt": "2018-01-10T12:29:58",
"date_modified": "2018-01-10T18:29:58",
"date_modified_gmt": "2018-01-10T12:29:58",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Code:-4105110568</p>\n",
"short_description": "<p>Code:-4105110568</p>\n",
"sku": "4105110568",
"price": "1971",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<div class=\"product-price\"><del><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">৳ </span> 2,190.00</span></del> <ins><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">৳ </span> 1,971.00</span></ins></div>",
"on_sale": true,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
47912,
47785,
47886,
48373,
48708
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 220,
"name": "Full Sleeve",
"slug": "full-sleeve-casual"
},
{
"id": 37,
"name": "Men",
"slug": "men"
},
{
"id": 53,
"name": "Shirt",
"slug": "shirt"
},
{
"id": 91,
"name": "Casual",
"slug": "casual"
}
],
"tags": [],
"images": [
{
"id": 57683,
"date_created": "2018-01-10T18:25:13",
"date_created_gmt": "2018-01-10T12:25:13",
"date_modified": "2018-01-10T18:25:13",
"date_modified_gmt": "2018-01-10T12:25:13",
"src": "https://infinitymegamall.com/wp-content/uploads/2018/01/Mens-Formal-Printed-Shirt-Sky-Print-4105110568-2190tk-2.png",
"name": "Mens Formal Printed Shirt-Sky Print—–4105110568—-2,190tk (2)",
"alt": "",
"position": 0
},
{
"id": 57684,
"date_created": "2018-01-10T18:25:33",
"date_created_gmt": "2018-01-10T12:25:33",
"date_modified": "2018-01-10T18:25:33",
"date_modified_gmt": "2018-01-10T12:25:33",
"src": "https://infinitymegamall.com/wp-content/uploads/2018/01/Mens-Formal-Printed-Shirt-Sky-Print-4105110568-2190tk-1.png",
"name": "Mens Formal Printed Shirt-Sky Print—–4105110568—-2,190tk (1)",
"alt": "",
"position": 1
}
],
"attributes": [
{
"id": 3,
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"L",
"M",
"XL"
]
}
],
"default_attributes": [],
"variations": [
57682,
57680,
57681
],
"grouped_products": [],
"menu_order": 0,
"meta_data": [
{
"id": 481056,
"key": "_vc_post_settings",
"value": {
"vc_grid_id": []
}
},
{
"id": 481216,
"key": "des_content",
"value": "Code:-4105110568"
},
{
"id": 481217,
"key": "trending_product",
"value": "off"
},
{
"id": 481269,
"key": "post_views",
"value": "3"
}
],
"_links": {
"self": [
{
"href": "https://infinitymegamall.com/wp-json/wc/v2/products/57678"
}
],
"collection": [
{
"href": "https://infinitymegamall.com/wp-json/wc/v2/products"
}
]
}
},
{
"id": 57672,
"name": "Mens Formal Printed Shirt",
"slug": "mens-formal-printed-shirt-2",
"permalink": "https://infinitymegamall.com/product/mens-formal-printed-shirt-2/",
"date_created": "2018-01-10T18:12:29",
"date_created_gmt": "2018-01-10T12:12:29",
"date_modified": "2018-01-10T18:12:29",
"date_modified_gmt": "2018-01-10T12:12:29",
"type": "variable",
"status": "publish",
"featured": false,
"catalog_visibility": "visible",
"description": "<p>Code:-4105110563</p>\n",
"short_description": "<p>Code:-4105110563</p>\n",
"sku": "4105110563",
"price": "1971",
"regular_price": "",
"sale_price": "",
"date_on_sale_from": null,
"date_on_sale_from_gmt": null,
"date_on_sale_to": null,
"date_on_sale_to_gmt": null,
"price_html": "<div class=\"product-price\"><del><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">৳ </span> 2,190.00</span></del> <ins><span class=\"woocommerce-Price-amount amount\"><span class=\"woocommerce-Price-currencySymbol\">৳ </span> 1,971.00</span></ins></div>",
"on_sale": true,
"purchasable": true,
"total_sales": 0,
"virtual": false,
"downloadable": false,
"downloads": [],
"download_limit": -1,
"download_expiry": -1,
"external_url": "",
"button_text": "",
"tax_status": "taxable",
"tax_class": "",
"manage_stock": false,
"stock_quantity": null,
"in_stock": true,
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"sold_individually": false,
"weight": "",
"dimensions": {
"length": "",
"width": "",
"height": ""
},
"shipping_required": true,
"shipping_taxable": true,
"shipping_class": "",
"shipping_class_id": 0,
"reviews_allowed": true,
"average_rating": "0.00",
"rating_count": 0,
"related_ids": [
48222,
48373,
47892,
50683,
48377
],
"upsell_ids": [],
"cross_sell_ids": [],
"parent_id": 0,
"purchase_note": "",
"categories": [
{
"id": 220,
"name": "Full Sleeve",
"slug": "full-sleeve-casual"
},
{
"id": 37,
"name": "Men",
"slug": "men"
},
{
"id": 53,
"name": "Shirt",
"slug": "shirt"
},
{
"id": 91,
"name": "Casual",
"slug": "casual"
}
],
"tags": [],
"images": [
{
"id": 57676,
"date_created": "2018-01-10T18:07:45",
"date_created_gmt": "2018-01-10T12:07:45",
"date_modified": "2018-01-10T18:07:45",
"date_modified_gmt": "2018-01-10T12:07:45",
"src": "https://infinitymegamall.com/wp-content/uploads/2018/01/Mens-Formal-Printed-Shirt-Maroon-4105110563-2190tk-2.png",
"name": "Mens Formal Printed Shirt-Maroon——4105110563—-2,190tk (2)",
"alt": "",
"position": 0
},
{
"id": 57677,
"date_created": "2018-01-10T18:08:25",
"date_created_gmt": "2018-01-10T12:08:25",
"date_modified": "2018-01-10T18:08:25",
"date_modified_gmt": "2018-01-10T12:08:25",
"src": "https://infinitymegamall.com/wp-content/uploads/2018/01/Mens-Formal-Printed-Shirt-Maroon-4105110563-2190tk-1.png",
"name": "Mens Formal Printed Shirt-Maroon——4105110563—-2,190tk (1)",
"alt": "",
"position": 1
}
],
"attributes": [
{
"id": 3,
"name": "Size",
"position": 0,
"visible": true,
"variation": true,
"options": [
"L",
"M",
"XL"
]
}
],
"default_attributes": [],
"variations": [
57673,
57674,
57675
],
"grouped_products": [],
"menu_order": 0,
"meta_data": [
{
"id": 480903,
"key": "_vc_post_settings",
"value": {
"vc_grid_id": []
}
},
{
"id": 481053,
"key": "des_content",
"value": "Code:-4105110563"
},
{
"id": 481054,
"key": "trending_product",
"value": "off"
},
{
"id": 481055,
"key": "post_views",
"value": "3"
}
],
"_links": {
"self": [
{
"href": "https://infinitymegamall.com/wp-json/wc/v2/products/57672"
}
],
"collection": [
{
"href": "https://infinitymegamall.com/wp-json/wc/v2/products"
}
]
}
}]
I am trying to download tweets from the London area using
curl --user xx:xx -X POST -d 'locations=-0.651,51.208,0.425,51.781' https://stream.twitter.com/1.1/statuses/filter.json > twitter.london.json
I am getting tweets that are way off. For example in (-6.71658144,50.48812681). Why is that?
The tweet:
{
"created_at": "Mon Apr 08 12:26:40 +0000 2013",
"id": 321237656321286144,
"id_str": "321237656321286144",
"text": "4dc9c54f70000000",
"source": "\u003ca href=\"http:\/\/www.google.com\/\" rel=\"nofollow\"\u003eGoogle\u003c\/a\u003e",
"truncated": false,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"user": {
"id": 61043461,
"id_str": "61043461",
"name": "GooGuns",
"screen_name": "googuns_prod",
"location": "",
"url": null,
"description": null,
"protected": false,
"followers_count": 86,
"friends_count": 0,
"listed_count": 2,
"created_at": "Tue Jul 28 22:49:22 +0000 2009",
"favourites_count": 0,
"utc_offset": -18000,
"time_zone": "Eastern Time (US & Canada)",
"geo_enabled": true,
"verified": false,
"statuses_count": 417708,
"lang": "en",
"contributors_enabled": false,
"is_translator": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png",
"profile_background_image_url_https": "https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png",
"profile_background_tile": false,
"profile_image_url": "http:\/\/a0.twimg.com\/sticky\/default_profile_images\/default_profile_3_normal.png",
"profile_image_url_https": "https:\/\/si0.twimg.com\/sticky\/default_profile_images\/default_profile_3_normal.png",
"profile_link_color": "0084B4",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"default_profile": true,
"default_profile_image": true,
"following": null,
"follow_request_sent": null,
"notifications": null
},
"geo": {
"type": "Point",
"coordinates": [50.48812681, -6.71658144]
},
* * "coordinates": {
"type": "Point",
"coordinates": [-6.71658144, 50.48812681]
},
* * "place": {
"id": "6416b8512febefc9",
"url": "http:\/\/api.twitter.com\/1\/geo\/id\/6416b8512febefc9.json",
"place_type": "country",
"name": "United Kingdom",
"full_name": "United Kingdom",
"country_code": "GB",
"country": "United Kingdom",
"contained_within": [],
"geometry": null,
"polylines": [],
"bounding_box": {
"type": "Polygon",
"coordinates": [
[
[-8.662663, 49.1626564],
[-8.662663, 60.86165],
[1.768926, 60.86165],
[1.768926, 49.1626564]
]
]
},
"attributes": {}
},
"contributors": null,
"retweet_count": 0,
"favorite_count": 0,
"entities": {
"hashtags": [],
"urls": [],
"user_mentions": []
},
"favorited": false,
"retweeted": false,
"filter_level": "medium",
"lang": "en"
}
According to the Twitter documentation, the location parameter accepts a comma separated list of longitude,latitude pairs specifying a set of bounding boxes.
If you just pass in a single latitude and longitude, then it will return the nearest Tweets to that location. Have you also specified a filter query, if so this will be massively cutting down the number of Tweets returned, meaning that the closest Tweet to London, is actually miles away. I had a similar problem.
Having said that, I just tried this out, if you use the lat and lon below, with NO other filter queries it works well.
{locations: [51.50,0.12,51.75,1.25]}
Another point to note, is that not a lot of Tweets actually have locations attached anymore, and often the ones which do are very inaccurate as they can actually be coming from the authors home location specified on their profile.