Make graphite's /render/?.... urls copy-pastable #158

Merged
merged 2 commits into from Aug 11, 2014

Projects

None yet
@seveas
Contributor
seveas commented Feb 24, 2013

Links to graphite images are completely unpastable to jabber/irc/mail as
clients mangle the humongous urls. These commits add a url shortener that can
shorten any graphite url from /what/ever/.... to /S/<base62_string>.

It can be used manually by prepending /s to the url path, and I added a button
to the graphite composer that does this for you.

Contributor
seveas commented Feb 24, 2013

Here's a screenshot of it in action:

shorturl

Member
SEJeff commented Feb 28, 2013

Haven't had a chance to test this yet, but I love the idea

Will give this a try tmo awesome stuff!

On Sunday, February 24, 2013, Dennis Kaarsemaker wrote:

Links to graphite images are completely unpastable to jabber/irc/mail as
clients mangle the humongous urls. These commits add a url shortener that
can
shorten any graphite url from /what/ever/.... to /S/.

It can be used manually by prepending /s to the url path, and I added a
button

to the graphite composer that does this for you.

You can merge this Pull Request by running

git pull https://github.com/seveas/graphite-web url_shortener

Or view, comment on, or merge it at:

#158
Commit Summary

  • Add url shortening views
  • Integrate the short url functionality with the composer

File Changes

  • A webapp/content/img/browser.pnghttps://github.com/graphite-project/graphite-web/pull/158/files#diff-0(0)
  • M webapp/content/js/composer_widgets.jshttps://github.com/graphite-project/graphite-web/pull/158/files#diff-1(15)
  • M webapp/graphite/app_settings.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-2(1)
  • A webapp/graphite/url_shortener/init.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-3(0)
  • A webapp/graphite/url_shortener/baseconv.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-4(58)
  • A webapp/graphite/url_shortener/models.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-5(5)
  • A webapp/graphite/url_shortener/views.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-6(24)
  • M webapp/graphite/urls.pyhttps://github.com/graphite-project/graphite-web/pull/158/files#diff-7(2)

Patch Links:

Contributor
seveas commented Feb 28, 2013

Thanks for considering. It's already proving pretty useful here, so I'm going to add links to create short urls to graphplot pages etc. as well.

How do I get this button to fetch the URL in my Graphite? I only have the first three buttons shown in the screenshot, missing the last two.

Owner

I'm not 👎 on this, but it seems like odd bedfellows (to me) to add a URL shortener into Graphite proper. I understand your hesitancy to leak URLs outside of your organization, but there's probably a better solution imho.

Contributor
seveas commented Apr 25, 2013

It's certainly possible to use an external url shortener app, but it's the integration with the graphite UI that made it 1000% more useful for us than an external app. So my definition of 'better' is more integration :)

@seveas seveas closed this Apr 25, 2013
@seveas seveas reopened this Apr 25, 2013
Owner

I get the usability aspect of it, but it's a slippery slope if we start integrating bits that are tangentially helpful. By that logic we could add "send to" buttons for email, Campfire, Facebook, etc. Just because we can doesn't mean we should.

Again, I'm not 👎 on this, just trying to offer a voice of reason.

Member
SEJeff commented Apr 25, 2013

It does suck quite a bit to send graphite urls in emails or IM especially to users with brain dead email clients that get confused by urls with () in them. It also sucks in markdown. External URL shorteners no way, but a simple and integrated one would be much appreciated by some users.

When sending links to less technical users, this is very valuable.

jmason commented May 14, 2013

sniping from the bikesheds: fwiw, I've seen a similar feature in Amazon's internal graphite-like system to deal with unpasteably humungous URLs.

++interest in this feature! Any chance it will be merged?

Owner

@SEJeff Have you gotten a chance to test this? It seems the community has spoken. 😏

Contributor

I've seen what @jmason is talking about: their graphing front-end auto-shortifies the link and displays it on the page. As an interim step, it would be awesome if the "Direct URL" button on the Dashboard gave me a complete link, as opposed to everything except the scheme and host. Extra points for auto-highlighting the whole line as it appears.

Member
SEJeff commented Jun 12, 2013

@obfuscurity I've not yet, but am going to shortly when I get home (travelling right now) at the end of the week. I'm in Boston at the moment

Contributor
seveas commented Jun 12, 2013

I just rebased the patches onto current master and pushed the result.

Contributor
seveas commented Jun 12, 2013

Just a datapoint as to how useful it is for us: in the 4 months since we added this, 666 short urls were created.

Owner

Clearly this is the devil's work at hand. Smite thine feature! 🔥

jmason commented Jun 13, 2013

\m/

syepes commented Jun 21, 2013

+1 This would be a great addition

I'd also love to see this added. Was just about to code it myself when i saw this.

I've been using this PR for a couple of months now and it has been really great - with one exception:
It seems that the default length for the URLField field type used in the model is 200 characters (https://docs.djangoproject.com/en/dev/ref/models/fields/#urlfield), a limit that I easily ran over with Graphite render URLs.

In fairness I only came across this problem after switching to a MySQL backend, so perhaps SQLite does not enforce this constraint?

To get around the problem I changed the url field type in url_shortener/models.py to "TextField" and then followed the alter table workaround described at http://code.djangoproject.com/ticket/2495 to trick MySQL and Django into playing nicely together when using a TextArea as part of a unique key.

I'm pretty new to django so I'm hoping there a better way to fix this.

Contributor
seveas commented Aug 23, 2013

Hmm, it's entirely possible that I did a manual alter table after syncdb, table definition here is:

url_shortener_link | CREATE TABLE `url_shortener_link` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` text NOT NULL,
  `date_submitted` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1123 DEFAULT CHARSET=utf8 
Member

I cherry picked this into my branch and it appears to be usable after these two commits:
cbowman0@bb776c6
cbowman0@a5efba4

I will be testing more.

@jmason jmason referenced this pull request in grafana/grafana Apr 1, 2014
Closed

Direct links to graphs #117

Owner

Sorry that this has languished for so long. If someone has the time and inclination to rebase this, I'd be happy to merge it.

seveas added some commits Aug 10, 2014
@seveas seveas Add URL shortening views
Links to graphite images are completely unpastable to jabber/irc/mail as
clients mangle the humongous urls. These commits add a url shortener
that can shorten any graphite url from /what/ever/.... to
/S/something_short.

It can be used manually by prepending /s to any url. This will return a
shortened version of that url. Subsequent commits will integrate this
with the composer and dashboard, and maybe other places.
e776d83
@seveas seveas Integrate the URL shortener
- The composer gets a button to shorten the URL to the current graph.
- The menu that appears when clicking on a graph in the dashboard
  gets a similar item.
514446d
Contributor
seveas commented Aug 10, 2014

I've pushed reworked commits based on todays master that include @cbowman0's changes.

Owner

Unless anyone has objections, I'd like to merge this in today or tomorrow. /cc @esc @brutasse @SEJeff

Member
SEJeff commented Aug 10, 2014

Please do, I for sure would use this functionality. I'd probably implement it differently, but this is entirely reasonable

Member
deniszh commented Aug 10, 2014

Using that patch (backported to 0.9.12) in production, haven't any troubles, even on sqlite

@obfuscurity obfuscurity merged commit b69aeb3 into graphite-project:master Aug 11, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
jmason commented Aug 11, 2014

awesome. thanks guys, looking forward to this ;)

Owner

Note that this is only in the master branch. I don't expect that we'd want to any significant features in the 0.9.x branch anytime soon; 0.9.13 is expected to be our last release from that branch. We'll focus on getting a 0.10 release from master after that.

Member

It'd be nice to mention this change in the 0.10 release notes.

@deniszh deniszh referenced this pull request Sep 6, 2014
Merged

0.9.x url shortener #938

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment