Creating one graph per node in Graphite and statsd - graphite

I am using graphite with statsd to collect various pieces of data from an application I have clustered in ec2. Among other things I have statistics for messages delivered by by application ond those that failed delivery. Because the number of consumers of messages of my application is somewhat fluid (changes every few days) I would like to be able to dynamicaaly generate graphs for these two stats per consumer. I post messages to statsd/graphite with the consumer id that is generated by the system as part of the stat:
stats.myapp.consumers.<consumerId>.messagesDelivered
stats.myapp.consumers.<consumerId>.messagesFailed
I currently generate two graphs using the wildcard for the consumerId:
stats.myapp.consumers.*.messagesDelivered
stats.myapp.consumers.*.messagesFailed
This is ok for a few consumers but I currently have >300 and it is growing rapidly. What I would like to be able to do is pass the above targets (or similar) and have graphite return a graph for each unique id. (I say graph but I am actually getting json results) I am currently using a personally modified version of the giraffe dashboard but am open to other suggestions.
Is this something that is even possible? (I suppose I could write some custom code to retrieve each id then generate the requests for each one each time. But I would really like to keep my customizations minimal if possible.)
I'm sure it's likely I will need to provide more details. Please let me know what you would need to know or if I am possibly just off-base with my request.
More details:
So, the end result of what I am hoping for is not to have one graph with, for lack of a better term, 300 lines each representing a node. I would like to have one graph for each node, each with two lines. One for delivered messages and one for failed messages.
When I attempted the solution from #Matt Self I ended-up with one graph with 300 lines on it. (Or, maybe I misinterpreted the suggestion?)

If I understand you correctly, I believe you can use groupByNode to do what you want:
groupByNode(stats.myapp.consumers.*.messagesDelivered,3,"sumSeries")
The 3 is used to indicate the unique id part of the bucket (e.g. stats=0,myapp=1,consumers=2,uniqueid=3,etc). And I used the sumSeries as the callback function in the example above, which it seems like might work for you, but you'll have to ensure you choose a function that makes sense for any series data you get per a unique id.
groupByNode used in this way (with the wildcard for the unique id) will return separate targets with datapoints for (grouped-by) each uniqueid.
Update based on comments:
While the above will create one rendered graph image with many graphs/lines based on a single input "target", the OP wants to create multiple independent graph images based on one input:
I don't know of a way render multiple graphs from the graphite url api (i.e. using graphite alone). Perhaps there is something in the dashboard that will accomplish it.
That said, you could do this with some simple html + javascript. Something like this might work (but you might have to tweak it):
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Multi-graph</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
var graphite_render_url = "http://some.graphite.host.blah.com/render/";
var mainTarget = "stats.myapp.consumers.*.messagesDelivered";
var mainFunc = "sumSeries";
var url = graphite_render_url + "?target=groupByNode(" + mainTarget + ",3,\"" + mainFunc + "\")";
url = url + "&format=json&jsonp=?";
$.getJSON(url, function(data){
for (var i = data.length - 1; i >= 0; i--) {
console.log(data[i]);
var imgSrc = graphite_render_url + "?target=";
var imgActual = mainTarget.replace('*',data[i].target);
$('#imagesList').append('<img src="' + imgSrc + imgActual + '" />');
};
});
</script>
</head>
<body>
<div id="imagesList"></div>
</body>
</html>
The above would insert an image for every unique returned target. This might not be exactly what you are looking for, but might get you headed down a working path.

Related

different array for more google map on same page

I have a problem with google map, delivery from this example: `Click here
I would like to create two maps, with different makers, and different paths on the same page that just does not seem to be able to pass new values ​​to google map for a different canvas-map based on the values ​​passed to the function.
In the my example: Click here clarifies my problem.
<p class="openmap" data-id="map">click here for map<p>
<p class="openmap" data-id="map1">click here for map1<p>
....
In the real script, the variable 'posts', is more complex and generates coordinates from html tables (two or more).
Someone has an idea how to fix?
The problem starts here:
function Tour_startUp(stops) {
if (!window.tour) window.tour = {
//code
}
}
It's obvious that Tour_startUp will do nothing when you call it the 2nd time, because on further calls the condition if (!window.tour) will be false. The result: both maps will use the same stops-argument that has been supplied at the first call.
Rethink the design of your application, avoid global variables and use OOP.

how to send two HTTP Requests at the same time

I created a method, which gets data from Foursquare(for venues), and Google(for streets), based on a latitude,longitude address I provide. It is intended to show locations around you. The name of the results from the two apis are then put together in a list
It looks something like this:
var httpFoursquareResponse = (HttpWebResponse)httpFoursquareWebRequest.GetResponse();
var httpGoogleResponse = (HttpWebResponse)httpGoogleWebRequest.GetResponse();
List<string> foursquarePlacesNames=getNames(httpFoursquareResponse);
List<string> googleStreetsNames=getStreets(httpFoursquareResponse);
var result=foursquarePlacesNames.Union(googleStreetsNames);
return result;
Problem:
1) I want the requests to be sent at the same time(so I don't have to wait for the first to get the second). But if I use AsyncCallbacks, how can I do that union, given the fact that I will have two responses handled by two different threads.
2) If more than 5 seconds pass and I have no response from one of the services, I want to return whatever data I have, and not care about the response anymore
How would you go about implementing something like this? I think it is a quite common scenario, but I didn't find any solutions on the web.
Thank you
You can use Asyncmanager for this thing.
Please get thetwo link for this. This would help you.
1.http://www.devproconnections.com/article/aspnet2/calling-web-services-asynchronously
2.http://www.c-sharpcorner.com/UploadFile/rmcochran/multithreadasyncwebservice05262007094719AM/multithreadasyncwebservice.aspx

Framebuster with exceptions

I have a question about writing a frame-buster-buster. I have already read Frame Buster Buster ... buster code needed but I need an extra tweak.
My content from my blog at [http://my_domain.c0m/blog] is being displayed at another site showing three "views". One view is a feed and doesn't particulary bother me. The other two bother me and I wish to break both. I also want to permit exceptions of domains with permission to frame.
In one view, it appears the the content from the top of my html of the top of my blog is first copied to create a "snapshot" [http://the_other_domain.c0m/copy_of_blog] then that copy is framed in [http://the_other_domain.c0m/ ]. So, in this case, the 'child' copy are both hosted at [http://the_other_domain.c0m/] . Google translate does a similar thing-- but I find this ok. So, I would like to break this frame while also permitting exceptions for google and also for people who have made a copy to their pcs and would like to view in a utility that might frame.
In the other view, it appears the content from my site is framed. So in this case [http://my_domain.c0m/blog_post] is framed by [http://the_other_domain.c0m/]. I would like to bust out of this frame. However, my difficulty is that I can't figure out how to do so while keeping the exceptions for google translate or individual pc users frames at home.
My solution so far (I am not particularly familiar with javascript. So, please don't laugh too hard at the redundancy and lack of knowledge):
I was able to bust the first frame using:
<SCRIPT type="text/javascript" >
var topWindow = String(top.location)
var topWord=topWindow.split("/")
var selfWindow = String(self.location)
var selfWord=topWindow.split("/")
var correctLocation ="http://my_domain.c0m/blog"
var correctWord2="my_domain.c0m"
var http="http:"
if( ( (topWord[2] != correctWord2) || (selfWord[2] != correctWord2) )
&& (topWord[2] != 'translate.googleusercontent.com' ) && (topWord[0] == http ) ){
document.write("message expressing my opinion about the asshattery going in here.]" )
setTimeout("redirect_after_pause()",8000)
}else{
//document.write("<p><font color='purple'>Hi there! Javascript is working.</font> </p> " )
}
function redirect_after_pause() {
var correctLocation ="http://my_domain.c0m/blog"
top.location=correctLocation
}
I know this is inefficient. But it works and achieves my goal of making an exception for a) translations at googlecontent which my readers in france requested and b) cases where a user is framing in a utility that downloads to their pc (which I think has uri's beginning with "FILE:".
Now the difficulty: This does not work for the view where content hosted at my domain is framed at the other domain. I believe I have tracked the problem down to var topWindow = String(top.location) not being permitted in my child window. In principle, this would work:
<script type="text/javascript">
if(top != self) top.location.replace(location);
However, I think it screws up the use of google translate which uses a top frame that holds their translation of my content also hosted at [http://translate.google.com]. I suspect it similarly screws up readers that might display a local copy on someones pc if that copy is displayed in a frame.
If someone can guide me toward a solution I can implement to break both frames while permitting my exception
BTW: It does appear that the site in question is using a framebuster. I poked around and found this inside their /static/common.js?1345250291 code:
enable_iframe_buster_buster:function(){var a=this,b=0;window.onbeforeunload=function(){b++};clearInterval(this.locks.iframe_buster_buster);this.locks.iframe_buster_buster=setInterval(function(){0<b&&(b-=2,a.flags.iframe_story_locations_fetched&&!a.flags.iframe_view_not_busting&&_.contains(["page","story"],a.story_view)&&NEWSBLUR.reader.active_feed&&($(".NB-feed-frame").attr("src",""),window.top.location="/reader/buster",$(".task_view_feed").click()))},1)},disable_iframe_buster_buster:function(){clearInterval(this.locks.iframe_buster_buster)}
That's deep inside some particulary dense javascript. Whatever it does it doesn't seem to affect my ability to bust the frame for the case where my content is copied and hosted at [http://the_other_domain.c0m/]. I haven't yet fully explored whether it busts simple framebusters because earlier I only recently recognized that " var topWindow = String(top.location) " was forbidden in the child frame with a different domain from the parent frame.
Whether or not the frame-buster is present, I'd like help with solutions here. I know that if one site is now framing my content in this way it is only a matter of time before the obnoxious technique catches on and I would like to code in solutions that bust both methods gracefully while providing myself with exceptions. Thanks in advance.

Dynamics GP Web Service -- Returning list of sales order based on specific criteria

For a web application, I need to get a list or collection of all SalesOrders that meet the folowing criteria:
Have a WarehouseKey.ID equal to "test", "lucmo" or "Inno"
Have Lines that have a QuantityToBackorder greater than 0
Have Lines that have a RequestedShipDate greater than current day.
I've succesfully used these two methods to retrieve documents, but I can't figure out how return only the ones that meet above criteria.
http://msdn.microsoft.com/en-us/library/cc508527.aspx
http://msdn.microsoft.com/en-us/library/cc508537.aspx
Please help!
Short answer: your query isn't possible through the GP Web Services. Even your warehouse key isn't an accepted criteria for GetSalesOrderList. To do what you want, you'll need to drop to eConnect or direct table access. eConnect has come a long way in .Net if you use the Microsoft.Dynamics.GP.eConnect and Microsoft.Dynamics.GP.eConnect.Serialization libraries (which I highly recommend). Even in eConnect, you're stuck with querying based on the document header rather than line item values, though, so direct table access may be the only way you're going to make it work.
In eConnect, the key piece you'll need is generating a valid RQeConnectOutType. Note the "ForList = 1" part. That's important. Since I've done something similar, here's what it might start out as (you'd need to experiment with the capabilities of the WhereClause, I've never done more than a straightforward equal):
private RQeConnectOutType getRequest(string warehouseId)
{
eConnectOut outDoc = new eConnectOut()
{
DOCTYPE = "Sales_Transaction",
OUTPUTTYPE = 1,
FORLIST = 1,
INDEX1FROM = "A001",
INDEX1TO = "Z001",
WhereClause = string.Format("WarehouseId = '{0}'", warehouseId)
};
RQeConnectOutType outType = new RQeConnectOutType()
{
eConnectOut = outDoc
};
return outType;
}
If you have to drop to direct table access, I recommend going through one of the built-in views. In this case, it looks like ReqSOLineView has the fields you need (LOCNCODE for the warehouseIds, QTYBAOR for backordered quantity, and ReqShipDate for requested ship date). Pull the SOPNUMBE and use them in a call to GetSalesOrderByKey.
And yes, hybrid solutions kinda suck rocks, but I've found you really have to adapt if you're going to use GP Web Services for anything with any complexity to it. Personally, I isolate my libraries by access type and then use libraries specific to whatever process I'm using to coordinate them. So I have Integration.GPWebServices, Integration.eConnect, and Integration.Data libraries that I use practically everywhere and then my individual process libraries coordinate on top of those.

InfoPath autonumber field

I am designing an infopath (Change Request) form:
1)How can i add a text box that automaticaly increments to the next number when a new form is created (adding a new Change Request form to the form library).
2)How do i retrieve information from an existing form to the new form.
NOTE: The field is not inside a repeating table. I need to generate the next Change Request number on each new Change Request form.
TIA!
There is no build-in way to do this, but there are several ways to achieve what you want (Database query or SPList query). But this kind of request somehow smells like a workaround for an other problem.
Common cases for increasing numbers are:
unique IDs
count the Requests
make referable by external list (same as ID)
make IDs guessable (time stamps are not)
If you need an ID: In most cases you are not forced to use integer IDs. Simply use the form title as a natural ID. (e.g. customer + timestamp)
If you need guessable IDs, you need them because an external system wants to access or refer to the request. In that case try to change the pull-direction into a push-direction (e.g. by using workflows) or let your other system provide a "getID" function that can be called by your form to obtain a known ID (no guessing needed).
Anyway - for me, it looks like you want to achieve this to solve some other problem. Maybe there are different solutions for that problem too?
You could enter a token in your text-titles on the form where you want autonumbering, such as #num#, and then use javascript or jquery to find those tokens and replace them with incremented numbers.
The drawback to this is that if you exported the list to excel, the tokens would not get translated to numbers. But it is a good solution for on-screen rendering.
Use Firebug to figure out the class of the container housing your autonumber tags.
Maybe you could do something like this:
function TokenReplacement(){
var ClassName = 'ms-formlabel';
var elements = new Array();
var elements = document.getElementsByTagName('td');
var numerator=0;
//Now do find and replace on everything else
for(var e=0;e<elements.length;e++){
thiselement = elements[e];
if(thiselement.className == ClassName){
//autonumber the questions by replacing the #num# token
if(thiselement.innerHTML.search('#num#') > -1){
numerator++
var replacenum = "<b>" + numerator + ". </b>";
thiselement.innerHTML = elements[e].innerHTML.replace('#num#',replacenum);
}
}
}
}

Resources